Skip to content

Add more Pulp Exceptions.#4419

Open
aKlimau wants to merge 2 commits into
pulp:mainfrom
aKlimau:add-pulp-exceptions
Open

Add more Pulp Exceptions.#4419
aKlimau wants to merge 2 commits into
pulp:mainfrom
aKlimau:add-pulp-exceptions

Conversation

@aKlimau
Copy link
Copy Markdown

@aKlimau aKlimau commented Apr 15, 2026

Assisted-by: Claude Sonnet 4.5 noreply@anthropic.com

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • A changelog entry or entries has been added for any significant changes
  • Follows the Pulp policy on AI Usage
  • (For new features) - User documentation and test coverage has been added

See: Pull Request Walkthrough

@aKlimau aKlimau marked this pull request as draft April 15, 2026 10:44
@aKlimau aKlimau force-pushed the add-pulp-exceptions branch 5 times, most recently from f298692 to 4b371ec Compare April 15, 2026 14:29
@aKlimau aKlimau force-pushed the add-pulp-exceptions branch 5 times, most recently from fdcbcde to 18e72d8 Compare April 29, 2026 08:34
@aKlimau aKlimau marked this pull request as ready for review April 29, 2026 12:49
@aKlimau aKlimau force-pushed the add-pulp-exceptions branch from 18e72d8 to fa0681b Compare May 4, 2026 13:27
  Assisted-by: Claude Sonnet 4.5 <noreply@anthropic.com>
@aKlimau aKlimau force-pushed the add-pulp-exceptions branch from fa0681b to f0a33c4 Compare May 13, 2026 14:23
@github-actions github-actions Bot added multi-commit Added when a PR consists of more than one commit no-changelog labels May 14, 2026
f"Failed to verify package signature: {completed_process.stdout} "
f"{completed_process.stderr}."
)
raise PackageSignatureVerificationError(completed_process.stdout, completed_process.stderr)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a note to myself (not something for this PR, as this already existed before), maybe we can process known output errors so we don't have to pass the full stderr (and then possibly log the raw stderr).

requested_checksum_type, ALLOWED_CHECKSUM_ERROR_MSG
)
)
raise DisallowedChecksumTypeError(requested_checksum_type, ALLOWED_CHECKSUM_ERROR_MSG)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ForbiddenChecksumTypeError and DisallowedChecksumTypeError looks like the same thing to me. Maybe we can pass down a context or extra message to the error for different contexts where it can be raised.

signed_package_path = Path(result["rpm_package"])
if not signed_package_path.exists():
raise Exception(f"Signing script did not create the signed package: {result}")
raise SigningScriptError(result)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think pulpcore InvalidSignatureError is appropriate here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually I think it's not quite the same. The one I mentioned is "Raised when a signature could not be verified.", but this workflow is about creating a package signature. Can you rename it to PackageSigningError ? Creation and verification are different enough

Another note to myself: maybe we can refine what is being passed here as well (e.g, the filename and fingerprint, instead of the signing script output, which can throw out anything).

if os.stat(signature_file_path).st_size == 0:
log.error(f"{signature_file_path} is 0 bytes! sign_results: {sign_results}")
raise Exception("Signature file is 0 bytes")
raise SignatureFileEmptyError()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is similar to the package signing error, but it's rpm metadata. Can you rename it to MetadataSigningError ?

"Please check your ACS remote configuration."
).format(custom_url, exc.status, exc.message)
)
raise RemoteFetchError(custom_url, exc.status, exc.message)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The information about this being an ACS remote error is relevant to the user here. Maybe we can use another exception for ACS (a subclass of this? i dont know), or just pass that info to the the message argument. Also, for RemoteFetchError, I would also pass the remote name, which is not a context readily available in the task without doing extra hops.


if not remote.url and not url:
raise ValueError(_("A remote must have a url specified to synchronize."))
raise SyncError("A remote must have a url specified to synchronize.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IHO this could be just a validation error, wdyt?
I don't even know when SyncError could be useful, since it's so vague. All errors raised here are running inside a task and will be available through the task object, right? So presumibly the user looking at this already knows it's looking at errors in an rpm sync.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can improve this changelog. Something like this (probably not exactly this): "Re-written generic exceptions as Pulp-specific exceptions, which represent known ways in which something can fail and are attached to specific error ids.". An if there is some documentation out there about this which might be relevant, it would be useful to link them here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

# can't be flagged as 'modular' thus broken repository!
if modulemd_result.url.endswith("zck"):
raise TypeError(_("Modular data compressed with ZCK is not supported."))
raise UnsupportedZckCompressionError()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I feel this should be UnsupportedModularCompressionError and zck be an argument.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's a bit brittle to review and read this direct error code matching on tests.
Can you use the pattern ClassError.error_code, instead of hard-coding the codes? E.g MissingPrimaryMetadataError.error_code in exc.value.task.error["description"]

f"Checksum {checksum} is unknown or too short to use for "
f"{self.publication.layout} publishing."
)
raise ChecksumTooShortError(checksum, self.publication.layout)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What do you think about transforming this into a LayoutValidationError, which accepts layout and known validation causes (e.g short_checksum=checksum for this case)? Then the exception class can be responsible for producing the appropriate message if other layout validation errors are introduced. I'm not 100% sure this is a good pattern, but this error feels soo much specific (and it only makes sense to the nested-by-digest layout, btw).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

multi-commit Added when a PR consists of more than one commit no-changelog no-issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants