fix(auth/external): tolerate OpenCode Go auth.json schema variants (#171)#248
Merged
Merged
Conversation
) Reported symptom: jcode server fails to start with 'No credentials configured' even though OpenCode Go login succeeded. Root cause: the parser only accepts the original OpenCode schema: {"type": "api", "key": "..."} OpenCode Go and several forks now ship variants: {"type": "api", "api_key": "..."} OpenCode Go newer {"type": "key", "key": "..."} some self-hosted forks { "key": "..."} type field absent { "token": "..."} OpenCode Go alt naming extract_api_key now accepts all four shapes: - type field optional; if present must be "api" or "key" - key field tried in order: "key" → "api_key" → "apiKey" → "token" OAuth-typed entries (type=="oauth") still rejected here so they go through the dedicated OAuth path — verified by a new regression test. 4 new tests: - opencode_api_key_accepts_api_key_field (OpenCode Go newer) - opencode_api_key_accepts_token_field (forks) - opencode_api_key_accepts_missing_type_field (loose) - opencode_api_key_rejects_oauth_typed_entry (negative) Closes #171.
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.
Symptom
jcode server fails with 'No credentials configured' even though OpenCode Go login succeeded.
Root cause
extract_api_keyforExternalAuthSource::OpenCodeonly accepted the original schema:{"type": "api", "key": "..."}But OpenCode Go and several forks now ship:
{"type": "api", "api_key": "..."}{"type": "key", "key": "..."}{ "key": "..." }(no type){ "token": "..." }Fix
extract_api_keynow accepts all four:typeoptional; if present must be"api"or"key"key→api_key→apiKey→tokenOAuth-typed entries still rejected here (they go through the dedicated OAuth path).
Tests
4 new tests covering each schema variant + an oauth-typed-entry negative test.
Closes #171.