Normalize API key display formatting#172
Open
IlyaasK wants to merge 8 commits into
Open
Conversation
Monitoring Plan: CLI API Key Display RefactorWhat this PR does: Refactors internal CLI rendering code for the Intended effect:
Risks:
Status updates will be posted automatically on this PR as monitoring progresses. |
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.
Summary
Normalizes API-key human-output formatting by mapping generated SDK responses into a small display model before rendering tables.
What changed
apiKeyDisplaymodel for API-key human output.newAPIKeyDisplay/newCreatedAPIKeyDisplay.JSON.*.Valid()presence checks inside the display mapper instead of scattering them through table rendering.--output jsonstill prints the raw SDK response.Why
The API-key CLI originally rendered directly from generated SDK models. That worked, but it leaked SDK presence metadata into render helpers. This keeps the command behavior unchanged while making the human-output boundary clearer: SDK object in, plain display strings out.
Verification
Automated checks:
env GOCACHE=/private/tmp/kernel-cli-go-cache go test ./pkg/utilenv GOCACHE=/private/tmp/kernel-cli-go-cache go test ./cmd -run 'TestAPIKey|TestProjects(List|Get|Limits)|TestBrowsers(Create_WithInvalidViewport|ParseUploadFileMappingRejectsBadMapping|ComputerPressKeyRequiresKeys)'make testmake buildLocalhost smoke against
http://localhost:3001:auth statussucceeded.app list --output jsonsucceeded.api-keys list --output jsonsucceeded.--project-id, get, update, delete, then post-delete not-found confirmation.projects list,projects get --output json, andprojects limits get --output jsonsucceeded.--include-deletedconfirmation.Production smoke against
https://api.onkernel.com:auth statussucceeded.app list --output jsonsucceeded.projects list --output jsonsucceeded.projects get --output jsonsucceeded against an existing production project.projects limits get --output jsonsucceeded against that project.api-keys list --output jsonsucceeded.--project-id, get, update, delete, then post-delete not-found confirmation.--include-deletedconfirmation.Endpoint-misconfiguration smoke:
KERNEL_BASE_URL=https://dashboard.onkernel.comnow reports a contextual API-base error instead of leaking an SDK HTML/JSON decode error.Autoreview:
python3 /Users/ilyaas/.codex/skills/autoreview/scripts/autoreview --mode branch --base origin/mainautoreview clean: no accepted/actionable findings reportedNote
Medium Risk
Large cross-command behavior change (errors now propagate instead of silent success) could affect scripts and exit codes; changes are mostly UX with no core auth logic rewrites.
Overview
This PR broadens CLI polish beyond API keys: it standardizes how commands validate flags, surface failures, and render human output.
API keys now map SDK models through an internal
apiKeyDisplaylayer so list/create/get tables use consistent scope, project, expiry, and creator strings (including SDKJSON.*.Valid()fallbacks). JSON paths are unchanged.Shared
pkg/utilhelpers centralize messages for required flags/args, mutually exclusive options, invalid enums, and not-found cases (with suggested list commands).CleanedUpSdkErroradds guidance when the API returns HTML (e.g. dashboard base URL). JSON helpers treat nil pages/slices as[], andAddSkipConfirmFlagreplaces duplicated-ywiring.Across
cmd/*(apps, browsers, deploy, auth, credentials, extensions, invoke, profiles, projects, proxies, status, etc.), many paths that previously printed withptermand returnednilnow return actionable errors; list/history JSON uses the new pagination helpers; delete commands share skip-confirm; and tests assert the new copy.Reviewed by Cursor Bugbot for commit 2f60cd7. Bugbot is set up for automated code reviews on this repo. Configure here.