opencode icon indicating copy to clipboard operation
opencode copied to clipboard

cli: filter auth list entries

Open ry2009 opened this issue 1 month ago • 7 comments

Only list credentials that validate against Auth.Info; skip $schema and other metadata keys so no “undefined” rows appear.

ry2009 avatar Dec 05 '25 17:12 ry2009

what behavior were u seeing before?

Can u show output of opencode auth list

rekram1-node avatar Dec 05 '25 17:12 rekram1-node

Auth file used

~/.local/share/opencode/auth.json
{
  "$schema": "https://example.com/schema",
  "openai": { "type": "api", "key": "sk-test" }
}

Old behavior (upstream/dev code):

$ bun run --cwd packages/opencode src/index.ts auth list
┌ Credentials ~/.local/share/opencode/auth.json │ ● $schema undefined │ ● OpenAI api │ └ 2 credentials

New behavior (branch fix/auth-list-filter):

$ bun run --cwd packages/opencode src/index.ts auth list
┌ Credentials ~/.local/share/opencode/auth.json │ ● OpenAI api │ └ 1 credentials

So the fix removes the not needed $schema undefined entry and only shows real providers.

ry2009 avatar Dec 05 '25 22:12 ry2009

I see, well that file shouldn't have the schema anyways i dont know why thatd be there, but realistically shouldn't this be filtered at the Auth.all() level? That way it applies elsewhere too?

rekram1-node avatar Dec 05 '25 22:12 rekram1-node

Or we could error on invalid values and tell user they corrupted the file or something

rekram1-node avatar Dec 05 '25 22:12 rekram1-node

Yeah I kept the filter in the CLI to stay minimal, since other call sites already ignore entries without a type, it was just the listing was noisy.

I’m happy to move the Auth.Info.safeParse into Auth.all() (and maybe log a warning for dropped keys) so all consumers get validated data.

ry2009 avatar Dec 05 '25 22:12 ry2009

I am unsure about hard errors because users tend to keep $schema in JSON, so failing the command might be worse dev exp than just a quiet skip but I can fold that into this PR too.

ry2009 avatar Dec 05 '25 22:12 ry2009

Hard error was just an idea doesnt have to be that

rekram1-node avatar Dec 05 '25 22:12 rekram1-node

For this did we want to move into the auth.all, should I go ahead and do that?

ry2009 avatar Dec 08 '25 03:12 ry2009

Yeah we should move it there

rekram1-node avatar Dec 08 '25 04:12 rekram1-node

if youre down yes plz

rekram1-node avatar Dec 08 '25 04:12 rekram1-node

/review

rekram1-node avatar Dec 08 '25 04:12 rekram1-node

lgtm

github-actions[bot] avatar Dec 08 '25 04:12 github-actions[bot]