Skip to content

fix: add more validations to project attributes #1335

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

Merged
merged 2 commits into from
Jun 5, 2025

Conversation

bzwei
Copy link
Collaborator

@bzwei bzwei commented Jun 3, 2025

Now validate project url, branch, and refspec

https://issues.redhat.com/browse/AAP-47166

@bzwei bzwei requested a review from a team as a code owner June 3, 2025 21:01
@bzwei bzwei force-pushed the git-validation branch from adfb5fe to 2d3968a Compare June 3, 2025 21:02
@bzwei bzwei added the run-e2e label Jun 3, 2025
@bzwei
Copy link
Collaborator Author

bzwei commented Jun 3, 2025

We can ignore the quality gate failures on security hotspots. Those tests are needed.

@bzwei bzwei requested a review from mkanoor June 3, 2025 21:12
@bzwei bzwei force-pushed the git-validation branch from 2d3968a to e5c3ccc Compare June 3, 2025 21:35
@codecov-commenter
Copy link

codecov-commenter commented Jun 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.91%. Comparing base (f01fbd6) to head (1353a92).

@@            Coverage Diff             @@
##             main    #1335      +/-   ##
==========================================
+ Coverage   93.87%   93.91%   +0.04%     
==========================================
  Files         318      318              
  Lines       18667    18742      +75     
==========================================
+ Hits        17523    17602      +79     
+ Misses       1144     1140       -4     
Flag Coverage Δ
unit-int-tests-3.11 93.85% <100.00%> (+0.04%) ⬆️
unit-int-tests-3.12 93.91% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/aap_eda/api/serializers/project.py 93.26% <100.00%> (+0.19%) ⬆️
src/aap_eda/core/validators.py 87.14% <100.00%> (+0.84%) ⬆️
src/aap_eda/services/project/scm.py 73.29% <100.00%> (+5.84%) ⬆️
tests/integration/api/test_project.py 99.43% <100.00%> (+0.02%) ⬆️
tests/unit/test_scm.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mkanoor
Copy link
Contributor

mkanoor commented Jun 3, 2025

@bzwei do we need to check the integration tests to see if the error comes in the correct field names so UI can display it.

@bzwei bzwei force-pushed the git-validation branch from e5c3ccc to e3edacd Compare June 4, 2025 14:31
@bzwei
Copy link
Collaborator Author

bzwei commented Jun 4, 2025

@bzwei do we need to check the integration tests to see if the error comes in the correct field names so UI can display it.

Added

@bzwei
Copy link
Collaborator Author

bzwei commented Jun 4, 2025

The e2e failure is fixed by https://github.com/ansible/eda-qa/pull/474.

Alex-Izquierdo
Alex-Izquierdo previously approved these changes Jun 4, 2025
Copy link
Collaborator

@Alex-Izquierdo Alex-Izquierdo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Regarding the comment from @mkanoor raw strings r'...' affects to how the backslashes are interpreted. Here they are escaped so it would not be necessary.

I personally prefer raw strings because it is easier to read and debug and less error prone. I suggest to change it but I won't block the PR for this. Up to you bill.

@Alex-Izquierdo
Copy link
Collaborator

sonar is complaining about a non covered line which git. I'm fine to ignore it, but it is also true that the test for it would be also simple.

@bzwei
Copy link
Collaborator Author

bzwei commented Jun 4, 2025

@Alex-Izquierdo fixed all. Please review again

@ptoscano
Copy link
Contributor

ptoscano commented Jun 5, 2025

There are two sonarqube reports on the "http" urls used in tests, because Using http protocol is insecure. Use https instead. It seems there is no way to disable a specific rule with an inline comment (like with flake8/pylint/etc):
https://community.sonarsource.com/t/python-add-inline-disabling-of-specific-rule/64184
(https://portal.productboard.com/sonarsource/3-sonarqube-server/c/755-python-users-can-suppress-specific-issues-with-nosonar-with-a-rule-key seems to be a way to request it more)
Another option, as mentioned in the above forum, is to disable sonarqube altogether for those two lines, eg:

        ("http://git.example.com/repo.git/sub/r2.git", True),  # /NOSONAR

IMHO either this, or let's ignore the issue altogether (which will show up in case those lines are changed again in the future).

Now validate project url, branch, and refspec
@bzwei bzwei force-pushed the git-validation branch from e0b5815 to 1e17643 Compare June 5, 2025 13:32
Copy link

sonarqubecloud bot commented Jun 5, 2025

@bzwei bzwei merged commit 2db001e into ansible:main Jun 5, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants