Repository navigation
fix(haiku): report a refused OAuth token instead of dropping it in silence - #184
Merged
Merged
Conversation
…lence Follow-up to #179, both findings from review of the merged change. A configured `REMEMBER_OAUTH_TOKEN` / `haiku.oauth_token` that failed the shape check was discarded without a word, so a typo'd or truncated token was indistinguishable from never having set one: the nested `claude -p` ran unauthenticated and produced exactly the confusing 401 the fallback exists to prevent, now with a misleading origin. The docs claimed it "fails at configuration time" — nothing failed. A refusal is now logged (source and length, never the value) into the daily log rather than stderr: `save-session.sh` captures `call-haiku`'s stderr to a temp file and only echoes it when the call *fails*, so a warning written there would vanish on the path that matters. An empty value stays silent — that is how the bundled config ships the key, and it reaches this code on every save. The config lookup now goes through the merged `REMEMBER_CONFIG` that lib-memory-dir.sh exports, instead of re-deriving the layer order in Python — one config resolution, not two free to drift (#177). The raw paths remain as a fallback for direct python use, where no shell wrapper ran. And lib-memory-dir.sh now creates that merged file under `umask 077` before any layer is written into it. Every entry point sources resolve-paths.sh (umask 077, #68) first, so it is already 600 in practice — but the file documents itself as sourceable on its own, and its mode must not depend on the caller now that it can carry a live credential. Tests: refusal is logged and the value is not; empty stays silent; a non-string value is refused; a malformed env token still falls through to a valid config one; the merged config wins over the raw project layer; the merged file is 600 with the caller's umask at 022. Three of them go red against the pre-fix code. Co-Authored-By: Max <noreply>
This was referenced Jul 27, 2026
fdaviddpt
added a commit
that referenced
this pull request
Jul 29, 2026
) The condition this fallback exists for — the Claude Code desktop/Agent-SDK host redacting CLAUDE_CODE_OAUTH_TOKEN from a spawned subprocess — cannot occur in CI, so the only evidence it works was a manual run reported in a comment on #179. This writes that procedure down: confirming the negative precondition, the positive assertion, the malformed-token case (#184), and what to record so a reader can judge staleness. Closes #197 Co-authored-by: t <[email protected]>
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.
Follow-up to #179 (merged as 0ffa30f). Both items came out of reviewing that change after it landed.
1. The refusal was silent — the PR's own stated goal
_looks_like_tokenrejected a malformedREMEMBER_OAUTH_TOKEN/haiku.oauth_tokenand returned nothing. No log, no raise. Reproduced against the merged code:call_haikuthen ran unauthenticated and produced the same confusing 401 the fallback exists to prevent — with a worse origin, since the operator could not tell "rejected" from "never set". README, CHANGELOG and the docstring all said the value "fails at configuration time". Nothing failed.A refusal is now reported: source and length, never the value. It goes to the daily log, not stderr —
save-session.shcapturescall-haiku's stderr to a temp file and only echoes it when the call fails, so a warning written there is discarded on exactly the path that matters.An empty value stays silent.
"oauth_token": ""is how the bundled config ships the key, and it reaches this code on every save through the merged config; warning on it would mean a WARNING line per save for every user.2. A second config reader, free to drift
_configured_oauth_token()hand-rolled its own layer order ($REMEMBER_DIR/config.json, then~/.remember/config.json), skipping the bundled-defaults layer and ignoringREMEMBER_CONFIG— the merged configlib-memory-dir.shbuilds from all three layers and exports before invoking the pipeline. That is the drift #177 tracks.It now reads
REMEMBER_CONFIGfirst. The raw paths stay as a fallback for direct python use (tests, a manualpython3 -m pipeline.shellcall) where no shell wrapper ran. The loopcontinues past a candidate whose key is present-but-empty rather than returningNone.3. Permissions on the merged config
Routing a credential through
${TMPDIR}/remember-config-$$.jsonraises the stakes on that file's mode. Sourced standalone it is 644:Not a live exposure: every entry point (
save-session.sh,run-consolidation.sh, and all three hooks) sourcesresolve-paths.shfirst, which setsumask 077(#68) — measured through the real chain it is already600. Butlib-memory-dir.shdocuments itself as sourceable on its own, so it now creates the file under(umask 077; : > ...)before any layer is written into it.jq's>, the jq-free Python merge, and thecpfallback all write into the existing file and keep its mode.Tests
Six new, in
tests/test_haiku.pyandtests/test_umask.py:oauth_tokenis refused and logged, and does not raiseREMEMBER_CONFIGwins over the raw project-layerconfig.jsonThree go red against the pre-fix code (
test_rejected_token_is_logged_not_silently_dropped,test_non_string_configured_token_is_rejected_and_logged,test_merged_config_wins_over_raw_project_config).test_empty_configured_token_logs_nothingpasses both ways by design — it guards against noise this change could have introduced.Full suite: 717 passed, 41 skipped.
Docs
README, CHANGELOG and
config.example.jsonno longer claim a configuration-time failure; they say the value is refused and reported in the daily log, and never passed to the CLI.Not changed
A misconfigured token produces the warning twice per save — summarize and NDC are two separate
call-haikuprocesses, so in-process dedup cannot work, and twice is still the right signal.