Skip to content

Conversation

@jgallagher
Copy link
Contributor

Fixes #9114.

// Attempt to make repo2 the target release. This should fail with a
// reasonable error message (it's been pruned).
let err = datastore
.target_release_insert(
Copy link
Collaborator

Choose a reason for hiding this comment

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

target_release_insert a UUID that does not exist?

Would it still claim to be pruned?

Comment on lines +147 to +155
let result = insert_into(dsl::target_release)
.values(selection)
.returning(TargetRelease::as_returning())
.get_result_async(&*conn)
.await
.optional()
.map_err(|e| {
public_error_from_diesel(e, ErrorHandler::Server)
})?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is probably the same as it was before, but does this do something reasonable if the INSERT fails for some other reason (like the generation number was already inserted)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I added a test for exactly that case, which still causes the insertion to fail with the same error it did before. The .optional() here only lets us handle "insert succeeded but returned 0 rows", which I believe can only be caused by the repo being pruned (the error we expect) or we got passed a UUID that isn't in the tuf_repo table at all (which would be a mistake somewhere else, and would only result in us claiming that the nonexistent repo was pruned instead of more clearly saying it doesn't exist).

@jgallagher jgallagher merged commit bb796b6 into main Sep 30, 2025
17 checks passed
@jgallagher jgallagher deleted the john/target-release-unpruned branch September 30, 2025 12:45
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.

must not be able to set target release to a pruned release

4 participants