Skip to content

Add --category to marketplace package add/set - #2626

Open
Tech Guy (lukiod) wants to merge 1 commit into
microsoft:mainfrom
lukiod:feat-marketplace-category-option
Open

Add --category to marketplace package add/set#2626
Tech Guy (lukiod) wants to merge 1 commit into
microsoft:mainfrom
lukiod:feat-marketplace-category-option

Conversation

@lukiod

Copy link
Copy Markdown
Contributor

Closes #2625.

Marketplace manifest entries already support a category field — the schema validates it (yml_schema.py, "must be a non-empty string") and the output mappers already emit it (output_mappers.py), per the issue's own description. The CLI only exposed --tags, so getting a category into marketplace.packages[] required a manual apm.yml edit.

Adds --category TEXT to both apm marketplace package add and apm marketplace package set, mirroring the existing --tags plumbing through yml_editor.py's add_plugin_entry/update_plugin_entry, with the same non-empty validation the schema already enforces on read (so an invalid/blank value fails immediately with an actionable message rather than persisting bad data that only fails later on check).

Verified end-to-end manually (marketplace package add ... --category "Productivity" persists correctly; --category " " fails with 'category' must be a non-empty string), plus new unit tests in test_yml_editor.py covering both the happy path and the validation error for add and set. Full marketplace test suite: 1511 passed. ruff check clean on all changed files.

Acceptance criteria from the issue:

  • Both commands accept --category
  • Invalid or blank categories fail with an actionable error
  • The field is persisted in marketplace.packages[]
  • apm marketplace check and apm pack preserve and emit category (already worked once present — pre-existing code, not touched here)
  • Command help and tests cover the new option

Marketplace manifest entries already support a category field (read,
validated, and emitted by the existing schema/output code), but the
CLI only exposed --tags, forcing manual apm.yml edits for categories.
Adds --category to both commands, mirroring the existing --tags
plumbing, with the same non-empty validation the schema already
enforces on read.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for a category field on marketplace plugin entries, including CLI flags, YAML editing logic, validation, and unit tests.

Changes:

  • Introduces category option to plugin add and plugin set commands.
  • Adds category to marketplace YAML add/update flows with validation.
  • Expands unit tests to cover category persistence and blank-category errors.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tests/unit/marketplace/test_yml_editor.py Adds assertions and new tests for category handling in add/update flows.
src/apm_cli/marketplace/yml_editor.py Adds _validate_category and wires category into add/update entry logic.
src/apm_cli/commands/marketplace/plugin/set.py Adds --category flag and passes it through to update fields.
src/apm_cli/commands/marketplace/plugin/add.py Adds --category flag and passes it through to entry creation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +154 to +157
def _validate_category(category: str) -> None:
"""Validate *category* is a non-empty string."""
if not isinstance(category, str) or not category.strip():
raise MarketplaceYmlError("'category' must be a non-empty string")
Comment on lines +238 to +239
if category is not None:
new_entry["category"] = category
Comment on lines 285 to 289
if key == "subdir":
_validate_subdir(fields[key])
elif key == "category":
_validate_category(fields[key])
entry[key] = fields[key]
@lukiod

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

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.

Add --category support to apm marketplace package add and set

2 participants