Skip to content

Conversation

@NexionisJake
Copy link

@NexionisJake NexionisJake commented Jul 30, 2025

[FIX] Prevent invalid commit hashes in test entries during CCExtractor releases

In raising this pull request, I confirm the following:

  • I have read and understood the contributors guide.
  • I have checked that another pull request for this purpose does not exist.
  • I have considered, and confirmed that this submission will be valuable to others.
  • I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • I give this submission freely, and claim no ownership to its content.

My familiarity with the project is as follows :

  • I have never used the project.
  • I have used the project briefly.
  • I have used the project extensively, but have not contributed previously.
  • I am an active contributor to the project.

Issue Description

When CCExtractor releases a new version, a test entry gets added with commit hash 0000000000000000000000000000000000000000 which is invalid. This blocks any test after that and causes issues with the testing pipeline.

Root Cause

The issue occurs in the release webhook handler in mod_ci/controllers.py. When processing a release event, the code uses GeneralData.query.filter(GeneralData.key == 'last_commit').first().value to get the commit hash, which may be invalid or contain zeros when there are issues with previous webhook processing.

Fix Implemented

This PR implements two key fixes:

  1. Added validation to add_test_entry function:

    • Prevents creation of test entries with invalid commit hashes
    • Adds detailed error logging when invalid hashes are detected
    • Skips test entry creation for empty, all-zero, or too-short commit hashes
  2. Fixed release webhook handler:

    • Uses GitHub API to fetch the actual commit hash from the release tag
    • Implements proper fallback with validation if tag lookup fails
    • Creates release records without updating test baselines when no valid commit hash can be determined
    • Only updates test baselines if a valid test entry exists for the commit

Benefits

  • No more test entries with invalid commit hashes like 0000000000000000000000000000000000000000
  • Releases are now associated with their correct commit hashes
  • System gracefully handles cases where commit hashes can't be determined
  • Invalid commits no longer block subsequent tests
  • Better error logging for easier troubleshooting

Testing

This fix has been tested by simulating GitHub webhook events for releases and verifying that:

  1. No invalid test entries are created
  2. Release version records are created correctly
  3. Test baselines are only updated when valid commit hashes are available

Related Issues

Fixes the long-standing issue where release events create invalid test entries.

@sonarqubecloud
Copy link

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.

1 participant