Fix subscription auth in BTW sub-sessions#25
Open
juicetin wants to merge 1 commit into
Open
Conversation
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
Fix
/btw, BTW model overrides, and/btw:summarizefor subscription and OAuth providers whose successful request authentication does not include an API key.The production change replaces three
apiKeypresence checks with theResolvedRequestAuth.okdiscriminator defined by Pi. API-key providers keep the same behavior.Context and root cause
Pi defines successful request authentication as:
The contract makes all three request fields optional.
getApiKeyAndHeaders()also has explicit successful paths that return headers without an API key. See Pi'sResolvedRequestAuthand resolver implementation and the successful keyless return paths.pi-btw treated
auth.ok && auth.apiKeyas success when selecting an override and treated!auth.apiKeyas failure before normal chat and summary sub-sessions. Valid subscription authentication therefore produced a missing-credentials error beforecreateAgentSession()could use the supplied model registry.I searched the repository's open and closed issues and pull requests for OAuth, subscription, API-key, and credential fixes. I did not find an existing proposal for this defect.
Affected upstream revision:
pi-btw0.4.1 at4f858102706910ee9d520a9666832f3103631b61. The same checks are present in the published 0.4.0 package.Reproduction
getApiKeyAndHeaders()resolves{ ok: true, headers, env? }withoutapiKey./btw:model./btw test subscription auth./btw:summarize, summarization fails at the same preflight check.Fix
Use
auth.okas the sole success discriminator at the three preflight sites:The existing
createAgentSession()calls still receivectx.modelRegistry, so Pi remains responsible for resolving the actual request authentication.ok: falsestill preserves the resolver's error and the existing fallback behavior.No dependencies, public APIs, persistence formats, or unrelated TUI behavior changed.
Automated tests
Added command-level regression coverage through pi-btw's registered public commands:
/btwchat with successful header/env subscription auth and no API key/btw:summarizewith successful header auth and no API keyok: falsemissing-credential and override-fallback cases remain coveredRed evidence before the production change:
Checks after the fix:
Production and rollout instructions
This is a client extension fix. It needs no data migration or configuration change.
After a release containing the patch, update
pi-btwand run/reloador restart Pi. Validate with the affected subscription model by running one/btwquestion and one/btw:summarizehandoff. Existing hidden BTW entries and API-key providers are unchanged.Rollback consists of reinstalling the previous
pi-btwrelease and reloading Pi. That restores the prior behavior, including the subscription-auth failure.Maintainer self-fix prompt
If you would rather reproduce and implement this independently, this prompt captures the observed contract and acceptance criteria: