Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing nil check for placement field in Policy health check #22060

Closed
3 tasks done
dhaiducek opened this issue Feb 27, 2025 · 3 comments · Fixed by #22057
Closed
3 tasks done

Missing nil check for placement field in Policy health check #22060

dhaiducek opened this issue Feb 27, 2025 · 3 comments · Fixed by #22057
Labels
bug Something isn't working version:2.14 Latest confirmed affected version is 2.14

Comments

@dhaiducek
Copy link
Contributor

dhaiducek commented Feb 27, 2025

Checklist:

  • I've searched in the docs and FAQ for my answer: https://bit.ly/argocd-faq.
  • I've included steps to reproduce the bug.
  • I've pasted the output of argocd version.

Describe the bug

When a Policy (from policy.open-cluster-management.io) has a status that is empty and non-nil (i.e. {}), the check for the status.placement field is throwing an error because it's doing a length check on a nil field:

<string>:10: __len undefined stack traceback: <string>:10: in main chunk [G]: ?

To Reproduce

Deploy a policy unattached to any placement.

Expected behavior

Health check does not throw an error.

Screenshots

--

Version

(Version is the version tied to the PR where the code was updated in #21297 )

2.14.0

Logs

--

@dhaiducek dhaiducek added the bug Something isn't working label Feb 27, 2025
@andrii-korotkov-verkada andrii-korotkov-verkada added the version:2.14 Latest confirmed affected version is 2.14 label Feb 28, 2025
@andrii-korotkov-verkada
Copy link
Contributor

Is it in Go code? I think len of nil is just 0.

@andrii-korotkov-verkada andrii-korotkov-verkada added the more-information-needed Further information is requested label Feb 28, 2025
@dhaiducek
Copy link
Contributor Author

@andrii-korotkov-verkada I was able to consistently reproduce it in the attached PR, #22057, so I think it's something about Lua. I don't know a whole lot about Lua, but it seems when obj.status is empty without any keys, I think the error comes when the script tries to do #obj.status.placement where since the placement key is already missing, so it's something more than just nil. I tried a trivial Lua program to confirm:

obj = {}
obj.status = {}

if #obj.status.placement > 0 then
    print("yay")
end
lua: main.lua:4: attempt to get length of a nil value (field 'placement')
stack traceback:
	main.lua:4: in main chunk
	[C]: in ? (exit status 1)

@andrii-korotkov-verkada
Copy link
Contributor

Thanks! I initially didn't realize it's Lua code, so it makes sense.

@andrii-korotkov-verkada andrii-korotkov-verkada removed the more-information-needed Further information is requested label Feb 28, 2025
jannfis pushed a commit that referenced this issue Feb 28, 2025
Signed-off-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com>
gcp-cherry-pick-bot bot pushed a commit that referenced this issue Feb 28, 2025
Signed-off-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com>
jannfis pushed a commit that referenced this issue Feb 28, 2025
…22057) (#22089)

Signed-off-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com>
Co-authored-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com>
chzar pushed a commit to chzar/argo-cd that referenced this issue Mar 3, 2025
…oproj#22057)

Signed-off-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com>
kingbj940429 pushed a commit to kingbj940429/argo-cd that referenced this issue Mar 4, 2025
…oproj#22057)

Signed-off-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com>
Signed-off-by: kingbj0429 <kingbj0429@lunit.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working version:2.14 Latest confirmed affected version is 2.14
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants