feat: deprecation warning for snap_daemon system username - #6250
Draft
lengau wants to merge 1 commit into
Draft
Conversation
Add a SystemUsernames pydantic model with snap_daemon marked as deprecated, so the JSON schema exposes 'deprecated: true' on that key. Also emit a runtime warning via craft-cli when snap_daemon is used. Fixes: #5448 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds explicit deprecation signaling for the snap_daemon entry under system-usernames, both in the runtime (via craft-cli warnings) and in the generated snapcraft.yaml JSON schema (via a dedicated pydantic model field marked deprecated), aligning Snapcraft with snapd’s deprecation of that username.
Changes:
- Introduces a
SystemUsernamespydantic model withsnap_daemonmarked deprecated and updatesProject.system_usernamesto use it. - Emits a runtime warning when
system-usernames.snap_daemonis present during project unmarshalling. - Updates snap.yaml metadata generation to serialize the new
SystemUsernamesmodel back into a plain dict, and adds/adjusts unit tests for the warning behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
snapcraft/models/project.py |
Adds SystemUsernames, switches Project.system_usernames to that model, and warns at runtime when snap_daemon is used. |
snapcraft/meta/snap_yaml.py |
Converts SystemUsernames back to a dict for snap.yaml generation via model_dump(). |
tests/unit/models/test_projects.py |
Updates system usernames assertions for model-based storage and adds warning/no-warning coverage. |
Comment on lines
+1268
to
+1277
| snap_daemon: Annotated[ | ||
| str | dict[str, Any] | None, | ||
| pydantic.Field( | ||
| default=None, | ||
| deprecated=( | ||
| "The 'snap_daemon' system username is deprecated. " | ||
| "See https://snapcraft.io/docs/system-usernames." | ||
| ), | ||
| ), | ||
| ] = None |
Comment on lines
+1268
to
+1276
| snap_daemon: Annotated[ | ||
| str | dict[str, Any] | None, | ||
| pydantic.Field( | ||
| default=None, | ||
| deprecated=( | ||
| "The 'snap_daemon' system username is deprecated. " | ||
| "See https://snapcraft.io/docs/system-usernames." | ||
| ), | ||
| ), |
Comment on lines
+1980
to
+1981
| cls, system_usernames: SystemUsernames | ||
| ) -> SystemUsernames: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a SystemUsernames pydantic model with snap_daemon marked as deprecated, so the JSON schema exposes 'deprecated: true' on that key. Also emit a runtime warning via craft-cli when snap_daemon is used.
Fixes: #5448
Describe your changes.
make lint && make test.