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: Allow to delete repos with invalid urls (#20921) #20975

Conversation

andrii-korotkov-verkada
Copy link
Contributor

@andrii-korotkov-verkada andrii-korotkov-verkada commented Nov 27, 2024

Fixes #20921

Normalization of repo url is attempted during repo deletion before comparison with existing repos. Before this change, it'd fail on invalid urls and return "", resulting in permission denied. This ended up in a state where people can add repos with invalid urls but couldn't delete them. Return raw repo url if url parsing failed. Add a test to validate the deletion can be performed and make sure it fails without the main change.

This needs to be cherry-picked to v2.11-2.13

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

@andrii-korotkov-verkada andrii-korotkov-verkada requested a review from a team as a code owner November 27, 2024 14:48
Copy link

bunnyshell bot commented Nov 27, 2024

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@andrii-korotkov-verkada andrii-korotkov-verkada force-pushed the 20921-fix-unable-to-delete-repo branch from a4ca51c to 1d7b5e3 Compare November 27, 2024 14:48
Fixes argoproj#20921

Normalization of repo url is attempted during repo deletion before comparison with existing repos. Before this change, it'd fail on invalid urls and return "", resulting in permission denied. This ended up in a state where people can add repos with invalid urls but couldn't delete them. Return raw repo url if url parsing failed. Add a test to validate the deletion can be performed and make sure it fails without the main change.

This needs to be cherry-picked to v2.11-2.13

Signed-off-by: Andrii Korotkov <[email protected]>
@andrii-korotkov-verkada andrii-korotkov-verkada force-pushed the 20921-fix-unable-to-delete-repo branch from 1d7b5e3 to 6ccd0fc Compare November 27, 2024 15:13
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@8bce61e). Learn more about missing BASE report.
Report is 15 commits behind head on master.

Files with missing lines Patch % Lines
util/git/git.go 62.50% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #20975   +/-   ##
=========================================
  Coverage          ?   55.02%           
=========================================
  Files             ?      324           
  Lines             ?    55472           
  Branches          ?        0           
=========================================
  Hits              ?    30522           
  Misses            ?    22329           
  Partials          ?     2621           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

util/git/git.go Outdated
// Similar to NormalizeGitURL, except returning a not fully normalized string when the url is invalid.
// Needed to allow a deletion of repos with invalid urls. See https://github.com/argoproj/argo-cd/issues/20921.
func NormalizeGitURLAllowInvalid(repo string) string {
return normalizeGitURL(repo, true)
Copy link
Member

Choose a reason for hiding this comment

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

I think it will be better not to add allowInvalid parameter to private function. Can we just return original "repo" in case if error happens ? In such case you will not need to modify with additional conditions normalizeGitURL function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made the change.

@reggie-k reggie-k added this to the v2.14 milestone Dec 2, 2024
@pasha-codefresh pasha-codefresh merged commit 155514e into argoproj:master Dec 2, 2024
27 checks passed
@andrii-korotkov-verkada
Copy link
Contributor Author

@pasha-codefresh, can we cherry pick this into 2.11-2.13, please?

adriananeci pushed a commit to adriananeci/argo-cd that referenced this pull request Dec 4, 2024
…oj#20975)

* fix: Allow to delete repos with invalid urls (argoproj#20921)

Fixes argoproj#20921

Normalization of repo url is attempted during repo deletion before comparison with existing repos. Before this change, it'd fail on invalid urls and return "", resulting in permission denied. This ended up in a state where people can add repos with invalid urls but couldn't delete them. Return raw repo url if url parsing failed. Add a test to validate the deletion can be performed and make sure it fails without the main change.

This needs to be cherry-picked to v2.11-2.13

Signed-off-by: Andrii Korotkov <[email protected]>

* Don't modify the original NormalizeGitURL

Signed-off-by: Andrii Korotkov <[email protected]>

---------

Signed-off-by: Andrii Korotkov <[email protected]>
Signed-off-by: Adrian Aneci <[email protected]>
@pasha-codefresh
Copy link
Member

/cherry-pick release-2.13

@pasha-codefresh
Copy link
Member

/cherry-pick release-2.12

gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Dec 10, 2024
* fix: Allow to delete repos with invalid urls (#20921)

Fixes #20921

Normalization of repo url is attempted during repo deletion before comparison with existing repos. Before this change, it'd fail on invalid urls and return "", resulting in permission denied. This ended up in a state where people can add repos with invalid urls but couldn't delete them. Return raw repo url if url parsing failed. Add a test to validate the deletion can be performed and make sure it fails without the main change.

This needs to be cherry-picked to v2.11-2.13

Signed-off-by: Andrii Korotkov <[email protected]>

* Don't modify the original NormalizeGitURL

Signed-off-by: Andrii Korotkov <[email protected]>

---------

Signed-off-by: Andrii Korotkov <[email protected]>
@pasha-codefresh
Copy link
Member

/cherry-pick release-2.11

gcp-cherry-pick-bot bot pushed a commit that referenced this pull request Dec 10, 2024
* fix: Allow to delete repos with invalid urls (#20921)

Fixes #20921

Normalization of repo url is attempted during repo deletion before comparison with existing repos. Before this change, it'd fail on invalid urls and return "", resulting in permission denied. This ended up in a state where people can add repos with invalid urls but couldn't delete them. Return raw repo url if url parsing failed. Add a test to validate the deletion can be performed and make sure it fails without the main change.

This needs to be cherry-picked to v2.11-2.13

Signed-off-by: Andrii Korotkov <[email protected]>

* Don't modify the original NormalizeGitURL

Signed-off-by: Andrii Korotkov <[email protected]>

---------

Signed-off-by: Andrii Korotkov <[email protected]>
Copy link

Cherry-pick failed with Merge error 155514e8caad2ec5878e55169c8b6c228d911bfe into temp-cherry-pick-9b2a18-release-2.11

@pasha-codefresh
Copy link
Member

2.11 has some conflicts, need to do it manually @andrii-korotkov-verkada

pasha-codefresh pushed a commit that referenced this pull request Dec 10, 2024
* fix: Allow to delete repos with invalid urls (#20921)

Fixes #20921

Normalization of repo url is attempted during repo deletion before comparison with existing repos. Before this change, it'd fail on invalid urls and return "", resulting in permission denied. This ended up in a state where people can add repos with invalid urls but couldn't delete them. Return raw repo url if url parsing failed. Add a test to validate the deletion can be performed and make sure it fails without the main change.

This needs to be cherry-picked to v2.11-2.13



* Don't modify the original NormalizeGitURL



---------

Signed-off-by: Andrii Korotkov <[email protected]>
Co-authored-by: Andrii Korotkov <[email protected]>
pasha-codefresh pushed a commit that referenced this pull request Dec 10, 2024
* fix: Allow to delete repos with invalid urls (#20921)

Fixes #20921

Normalization of repo url is attempted during repo deletion before comparison with existing repos. Before this change, it'd fail on invalid urls and return "", resulting in permission denied. This ended up in a state where people can add repos with invalid urls but couldn't delete them. Return raw repo url if url parsing failed. Add a test to validate the deletion can be performed and make sure it fails without the main change.

This needs to be cherry-picked to v2.11-2.13



* Don't modify the original NormalizeGitURL



---------

Signed-off-by: Andrii Korotkov <[email protected]>
Co-authored-by: Andrii Korotkov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Status: Completed
Development

Successfully merging this pull request may close these issues.

Trying to delete a repo I added by mistake and getting "permission denied"
3 participants