refactor: migrate upload-metadata
Metadata
Current evaluation
Merged after two approvals and CI validation. The change refactored and migrated legacy upload-metadata command code to modern standards, incorporating type hints, craft_cli, and rewritten unit tests without behavioral changes. Partially resolves #5338.
Suggested action: —
No scores available.
Issue body
Migrates all legacy code for the `upload-metadata` command. No behavioral changes.
This is as pure of a refactor as I could manage. I made minor changes like updating from `logger` to `craft_cli`, adding type hints, and clarifying docstrings.
That means there are plenty of inefficiencies and bugs. For example, you'll see places where we access dict values without guarding against KeyErrors or error messages that begin with "Sorry". I left all this code as-is to limit what reviewers need to focus on (the migration, not the implementation). Otherwise, this review would take forever.
The unit tests had to be completely rewritten. They were using `unittest` and a bit of a mess due to their age and neglect.
Unfortunately, there was very little code that I could remove from `snapcraft_legacy`, as the code is still used for other store commands still in snapcraft_legacy.
I recommend reviewing this by commit.
Partially completes #5338
(SNAPCRAFT-764)
---
- [x] I've followed the [contribution guidelines](https://github.com/canonical/snapcraft/blob/main/CONTRIBUTING.md).
- [x] I've signed the [CLA](http://www.ubuntu.com/legal/contributors/).
- [x] I've successfully run `make lint && make test`.
- [ ] I've added or updated any relevant documentation.
- [ ] I've updated the relevant release notes.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged after two approvals and CI validation. The change refactored and migrated legacy upload-metadata command code to modern standards, incorporating type hints, craft_cli, and rewritten unit tests without behavioral changes. Partially resolves #5338. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged legacy upload-metadata migration. Updated logging to craft_cli, added type hints, and rewrote unit tests. No behavioral changes. Preserved inefficiencies to streamline review. Addressed API comments and force-pushed for a clean rebase before merge. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged a refactor migrating legacy upload-metadata code. Replaces logger with craft_cli, adds type hints, and rewrites unit tests. Inefficiencies were retained to streamline review. Branch was rebased and merged. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #5401 docs: migrate metadata reference | snapcraft | merged | Merged following approval from two reviewers and successful CI validation. The change migrates external metadata documentation to a new reference page, adding 139 lines across two files to resolve SNAPCRAFT-433. |