Skip to content

Ensure provider name is set during repo delete#3219

Closed
dmjb wants to merge 1 commit intomainfrom
provider-name-enforced-delete
Closed

Ensure provider name is set during repo delete#3219
dmjb wants to merge 1 commit intomainfrom
provider-name-enforced-delete

Conversation

@dmjb
Copy link
Copy Markdown
Contributor

@dmjb dmjb commented May 1, 2024

When handling a request to delete a repository by name, Minder does not enforce that the request contains a non empty provider name. The SQL query used to find the repository will ignore the provider field if the provider name is empty. This leads to a potential bug which could arise if there is more than one repo with the same name in the same project, but with different providers. In this case, one of the repos will get deleted, but it is not deterministic which one will get deleted from the client's viewpoint.

This introduces a slight API compatibility change, but at least avoids the bug described above.

Summary

Provide a brief overview of the changes and the issue being addressed.
Explain the rationale and any background necessary for understanding the changes.
List dependencies required by this change, if any.

Fixes #(related issue)

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Outline how the changes were tested, including steps to reproduce and any relevant configurations.
Attach screenshots if helpful.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

@dmjb dmjb requested a review from a team May 1, 2024 08:01
@coveralls
Copy link
Copy Markdown

coveralls commented May 1, 2024

Coverage Status

coverage: 50.534% (+0.02%) from 50.514%
when pulling 0acfeea on provider-name-enforced-delete
into 3fe6420 on main.

@dmjb dmjb marked this pull request as draft May 1, 2024 08:11
This was an inadvertant change introduced by my previous PR which
refactored the repo deletion flow. Prior to my PR, the code implicitly
validated that the provider name was non empty by setting `Valid` to
true in the `sql.NullString` used to query repos by provider name. This
change restores that behaviour, adds comments, and also adds explicit
validation in the controlplane to ensure that provider name is set.

Since an empty provider name would always have led to an error, I do not
believe that this extra validation constitutes a breaking change. It
will however change the response code in this case from a 404 to a 400.
@dmjb dmjb force-pushed the provider-name-enforced-delete branch from aaac299 to 0acfeea Compare May 1, 2024 08:16
@dmjb
Copy link
Copy Markdown
Contributor Author

dmjb commented May 1, 2024

Closing this for now since fixing it may involve breaking the CLI. Will open an issue to track this.

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.

2 participants