Skip to content

fix(policy): close dead ends found in a test of the policy commands - #76

Merged
Sahilb315 merged 3 commits into
mainfrom
fix/policy-cli-qa-findings
Nov 10, 2026
Merged

Sahilb315 merged 3 commits into
mainfrom
fix/policy-cli-qa-findings

Conversation

@Sahilb315

@Sahilb315 Sahilb315 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

I tested main (fd36142) against v0.10.0 on a live tenant, with about 250 command calls. This PR fixes the findings that are CLI bugs. It does not add a check for each bad input.

Fixes

Command Before After
project show For an ambiguous name, the error said to retry with a project ID. The command took a name only, so the user had no next step. New --project-id flag, as project policy show has. The error names the flag.
policy revision show N, policy get --revision N A revision that does not exist gave "Resource not found". "Policy revision N does not exist", with the hint that policy change create gives.
policy change show A published or deleted change that edited the settings said "The change edits nothing". The text says that the change edited the settings, and points to policy revision show N.
policy change delete A change that is not open gave a hint about policy overrides. The hint lists the open changes.
audit event list A bad --resource kind or --page-token gave "Invalid request". The error shows the reason that the server sent.
policy rule delete The delete of a block entry loosened the policy and published at once, with no confirmation. For a block entry the command asks in a terminal, and needs --yes when no terminal is present, as policy change publish does. A trust entry does not ask.

project show --project-id reads the project through the safedep.io/project-id label, because the ListProjects filter has no project ID field.

Not changed, and why

  • --vers with an invalid range is accepted. The CLI keeps its base checks (PURL form, length, version and range not together). The server already refuses a selector that a tool would drop, so the range check belongs there.
  • Bad --page-token gives a 500 on policy revision list, policy change list and policy rule list. This is a server bug.
  • policy rule list --at-revision above head returns the head rules. This is server behavior.
  • policy rule create -o json writes no JSON. DEVGUIDE defines operational commands as dry/tui messages only.
  • 7d in the table, 168h in plain and JSON. DEVGUIDE says that only RenderTable humanizes.
  • policy decision list -o json has raw enum names. The code writes the server message on purpose.
  • policy change edit -m needs a terminal. The command is an editor command.
  • A new override with a cooldown shows as LOOSENS. The server sets the direction, and the docs show the same.

Test plan

  • go test ./... and go vet ./...
  • go test ./internal/cmd/ -run Conventions
  • Each fix checked against a live tenant with read-only commands
  • golangci-lint passes in CI
  • The prompt of policy rule delete is not run on a live tenant. Unit tests cover it.

🤖 Generated with Claude Code

- project show: add --project-id. The error for an ambiguous name told
  the user to retry with a project ID, but the command took a name only.
- policy revision show, policy get --revision: say that the revision
  does not exist, as policy change create does.
- policy change show: a closed change that edited the settings said
  "The change edits nothing". It now points to the published revision.
- policy change delete: the hint for a change that is not open no
  longer talks about policy overrides.
- audit event list: show why the server refused a filter or a page
  token, in place of "Invalid request".

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: 61d92afc-3613-4125-b42e-60fe81e021c9
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@Sahilb315
Sahilb315 marked this pull request as ready for review November 10, 2026 12:17
@safedep

safedep Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

View complete scan results →

This report is generated by SafeDep GitHub App

Sahilb315 and others added 2 commits November 10, 2026 17:58
The delete of a block entry loosens the policy and publishes at once.
The command now reads the rule first. For a block entry it asks in a
terminal, and needs --yes when no terminal is present, as policy change
publish does. The delete of a trust entry does not ask.

Co-Authored-By: Claude <noreply@anthropic.com>
- project show: after a read with --project-id, the footer gives the
  policy command with the ID, because the name can be ambiguous.
- policy change show: a closed change that edited the settings and has
  rule operations now also says where the settings are.
- audit event list: the help for a refused request names the flags, not
  only the filters. A bad page token is not a filter.
- policy rule delete: with --yes the command does not read the rule.
- policy get: the error of a failed read has the revision number again.

Co-Authored-By: Claude <noreply@anthropic.com>
@Sahilb315
Sahilb315 merged commit 012423b into main Nov 10, 2026
7 checks passed
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.

2 participants