Skip to content

organization/api-keys: fix broken code samples and clarify role pathway#5024

Open
shannonbradshaw wants to merge 2 commits into
viamrobotics:mainfrom
shannonbradshaw:api-keys-correctness
Open

organization/api-keys: fix broken code samples and clarify role pathway#5024
shannonbradshaw wants to merge 2 commits into
viamrobotics:mainfrom
shannonbradshaw:api-keys-correctness

Conversation

@shannonbradshaw
Copy link
Copy Markdown
Collaborator

Summary

  • Operator role pathway clarified. Page claimed keys are Owner or Operator and the recommended-scope table suggested Operator for some rows, but viam organizations api-key create, locations api-key create, and machines api-key create all hardcode *_owner (no --role flag), and the Web UI also creates Owner only (TODO comment in app/ui/src/.../create-api-key.svelte:93). Operator-role keys are reachable only through the Python SDK with APIKeyAuthorization(role="operator", ...). Split the section into "Choose the right scope" (scope-only table) and "Choose the role" (Owner vs Operator with the limitation called out), and added a concrete Operator-key Python example.
  • Five broken code samples fixed:
    • Python list_keyskey.api_key_id/key.name would AttributeError; correct fields are key.api_key.id/key.api_key.name (viam-python-sdk:src/viam/app/app_client.py:2556, api/proto/viam/app/v1/app.proto:1884,961).
    • Go ListKeyskey.APIKeyID/key.Name doesn't compile; APIKeyWithAuthorizations exposes APIKey *APIKey (rdk/app/app_client.go:280-291).
    • Go RotateKey — variables newKey, newKeyID were swapped; signature returns (id, key, error) (rdk/app/app_client.go:2868-2876).
    • Go RenameKeyerr := is a compile error; signature returns (string, string, error) (rdk/app/app_client.go:2848-2857).
    • CLI output examples — Key: is wrong; actual field label is Key Value:, plus the prefix and warning lines (rdk/cli/auth.go:330-333,410-413,474-477).

Test plan

  • vale docs/organization/api-keys.md passes (0 errors)
  • npx prettier --check passes
  • npx markdownlint-cli passes
  • make build-prod builds clean
  • All four internal links resolve (/organization/overview/, #create-an-operator-role-key, /organization/rbac/, /organization/overview/#cli-authentication)
  • Python code blocks ast.parse clean
  • Reviewer to verify Netlify deploy preview renders correctly

🤖 Generated with Claude Code

- Separate scope and role decisions; CLI/UI create Owner only.
- Add Operator-key Python example (the only path).
- Fix Python list_keys (key.api_key.id, not key.api_key_id).
- Fix Go ListKeys field access (key.APIKey.ID, not key.APIKeyID).
- Fix Go RotateKey return order (id, key — not key, id).
- Fix Go RenameKey return arity (returns (string, string, error)).
- Update CLI output blocks to actual format (Key Value, success+warning lines).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 26, 2026

Deploy Preview for viam-docs ready!

Name Link
🔨 Latest commit c7ea110
🔍 Latest deploy log https://app.netlify.com/projects/viam-docs/deploys/69f4ffb02e7f520008ebbc52
😎 Deploy Preview https://deploy-preview-5024--viam-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 32 (🔴 down 6 from production)
Accessibility: 99 (no change from production)
Best Practices: 92 (🟢 up 9 from production)
SEO: 89 (🔴 down 3 from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@viambot viambot added the safe to build This pull request is marked safe to build from a trusted zone label Apr 26, 2026
@viamrobotics-overwatch
Copy link
Copy Markdown

Hey @shannonbradshaw — CI is green and no reviewer is assigned yet. Could you request one when you have a chance?

Auto-comment from overwatch. Will not re-nudge for 7 days.

The Viam app's create-key form has a Role dropdown supporting Owner
or Operator (org and location forms both use roleNames =
[RoleName.OWNER, RoleName.OPERATOR]), and the Go SDK exposes
AuthRoleOperator alongside AuthRoleOwner. Only the CLI is hardcoded
to Owner.

Replace the "Python SDK is the only path to Operator-role keys"
framing with a matrix that names the actual limitation (CLI), and
reframe the Operator example as one SDK example among the supported
paths.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@viamrobotics-overwatch
Copy link
Copy Markdown

Hey @shannonbradshaw — CI is green and no reviewer is assigned yet. Could you request one when you have a chance?

Auto-comment from overwatch. Will not re-nudge for 7 days.

1 similar comment
@viamrobotics-overwatch
Copy link
Copy Markdown

Hey @shannonbradshaw — CI is green and no reviewer is assigned yet. Could you request one when you have a chance?

Auto-comment from overwatch. Will not re-nudge for 7 days.

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

Labels

safe to build This pull request is marked safe to build from a trusted zone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants