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

fix: add missing null checks for notification triggers on ArgoCD sync failed (issue no #21591) #21679

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

prashant231203
Copy link

Title: Fix nil operationState issue in argocd-notifications

Summary:

This PR resolves the issue where ArgoCD Notifications fails with errors when accessing the operationState for uninitialized applications (i.e., when the value is null). The solution ensures that null checks are added in all triggers before attempting to access the operationState.phase, preventing the error.

Issue:

Error:
This error occurs when an application either lacks the operationState or has an uninitialized operationState object. In such cases, the condition attempts to check operationState.phase, which throws an error because the reference is null.

Fix:

What was changed:
This fix modifies the condition checks in the notification YAML to ensure that operationState is properly validated (i.e., nil checks) before any attempt to access its properties, like operationState.phase.

  • Added explicit nil checks for operationState across all when conditions in the triggers, such as on-sync-running, on-deployed, on-sync-succeeded, and on-sync-failed.

Expected Outcome:

  • When the application is still being synced or lacks a valid operationState, it should not cause an error.

  • Notifications should be successfully triggered regardless of whether the operationState exists, as long as all when conditions are properly checked for null values.

  • After fix (successful notification without errors):
    Provide logs demonstrating that the notifications now trigger without issues.

Additional Notes:

  • This change ensures backward compatibility with existing setups where operationState might not yet be initialized for newly created applications or applications in a non-running state.
  • Ensures more robust error handling and reliability in ArgoCD notification conditions, particularly in edge cases where the application state is not fully initialized.

@prashant231203 prashant231203 requested a review from a team as a code owner January 27, 2025 10:27
Copy link

bunnyshell bot commented Jan 27, 2025

🔴 Preview Environment stopped on Bunnyshell

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔵 /bns:start to start the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

@prashant231203 prashant231203 force-pushed the master branch 2 times, most recently from e08f602 to 2306884 Compare January 27, 2025 11:27
prashant231203 and others added 12 commits January 27, 2025 12:01
argoproj#21658)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Prashant singh <[email protected]>
Signed-off-by: Prashant singh <[email protected]>
Signed-off-by: Prashant singh <[email protected]>
Signed-off-by: Prashant singh <[email protected]>
Signed-off-by: Prashant singh <[email protected]>
Signed-off-by: Prashant singh <[email protected]>
Signed-off-by: Prashant singh <[email protected]>
Signed-off-by: Prashant singh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants