Skip to content

Fix unnecessary API calls when project already associated(AST-137848)#1473

Open
cx-sumit-morchhale wants to merge 3 commits intomainfrom
bug/AST-137848-projAppAsso
Open

Fix unnecessary API calls when project already associated(AST-137848)#1473
cx-sumit-morchhale wants to merge 3 commits intomainfrom
bug/AST-137848-projAppAsso

Conversation

@cx-sumit-morchhale
Copy link
Copy Markdown
Contributor

Consolidated duplicate project association checks at the findApplicationAndUpdate entry point to prevent unnecessary API calls.

Changes:

  • Added top-level check in findApplicationAndUpdate to skip API calls when projectID already in ProjectIds
  • Removed redundant internal check from associateProjectToApplication function
  • Rewrote tests to verify behavior at entry point for both flag states

The fix ensures:
✅ No unnecessary CreateProjectAssociation API calls when flag is ENABLED ✅ No unnecessary UpdateApplication API calls when flag is DISABLED ✅ Single responsibility principle - check happens at entry point only ✅ All tests pass with no regressions

By submitting this pull request, you agree to the terms within the Checkmarx Code of Conduct. Please review the contributing guidelines for guidance on creating high-quality pull requests.

Description

Please provide a summary of the changes and the related issue. Include relevant motivation and context.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update

Related Issues

Link any related issues or tickets.

Checklist

  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules
  • I have updated the CLI help for new/changed functionality in this PR (if applicable)
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used

Screenshots (if applicable)

Add screenshots to help explain your changes.

Additional Notes

Add any other relevant information.

Consolidated duplicate project association checks at the findApplicationAndUpdate entry point
to prevent unnecessary API calls for both flag enabled and disabled states.

Changes:
- Added top-level check in findApplicationAndUpdate to skip API calls when projectID already in ProjectIds
- Removed redundant internal check from associateProjectToApplication function
- Rewrote tests to verify behavior at entry point for both flag states

The fix ensures:
✅ No unnecessary CreateProjectAssociation API calls when flag is ENABLED
✅ No unnecessary UpdateApplication API calls when flag is DISABLED
✅ Single responsibility principle - check happens at entry point only
✅ All tests pass with no regressions

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 13, 2026

Logo
Checkmarx One – Scan Summary & Details4393df63-b046-46bf-8014-8942c965f43d

Great job! No new security vulnerabilities introduced in this pull request

cx-sumit-morchhale and others added 2 commits April 13, 2026 16:02
Extract repeated string literals into constants to satisfy goconst linter:
- mockApplicationName = "MOCK" (used in 2 tests)
- testProjectName = "test-project" (used in 2 tests)

This follows Go best practices for test constants and resolves linting warnings.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Remove "MOCK" from default ProjectIds to fix integration tests that expect new project associations
- Keep "ID-newProject" in ProjectIds only for ExistingApplication to preserve polling test functionality
- Maintain ProjectID1, ProjectID2, test_project, ID-new-project-name in default list for unit tests
- Fixes issue where MOCK project was incorrectly marked as already associated in 3 integration tests
- Ensures top-level duplicate check in findApplicationAndUpdate works correctly for both flag states

Fixes: AST-137848

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant