Skip to content

fix(cloud): send Authorization header on sync --cloud using file token fallback#430

Merged
Alan-TheGentleman merged 1 commit into
mainfrom
fix/sync-cloud-auth-header
May 27, 2026
Merged

fix(cloud): send Authorization header on sync --cloud using file token fallback#430
Alan-TheGentleman merged 1 commit into
mainfrom
fix/sync-cloud-auth-header

Conversation

@Alan-TheGentleman
Copy link
Copy Markdown
Collaborator

Summary

  • resolveCloudRuntimeConfig in cmd/engram/main.go zeroed cc.Token before reading ENGRAM_CLOUD_TOKEN, so any token persisted in cloud.json was silently discarded on every call.
  • Users running engram sync --cloud in a fresh shell without ENGRAM_CLOUD_TOKEN exported always got 401, even with a valid token in cloud.json (no Authorization header was sent).
  • Fix: remove the blanket cc.Token = "". The file token is now a fallback; the env var still takes precedence when set.

Test plan

  • TestResolveCloudRuntimeConfigFallsBackToFileToken — file token used when env absent
  • TestResolveCloudRuntimeConfigEnvTokenTakesPrecedence — env overrides file token
  • TestSyncCloudSendsAuthorizationHeaderFromFileToken — e2e via httptest: Authorization: Bearer <token> present on the actual request
  • go test ./... && go vet ./... && go build ./... clean

Closes #343

…unset

resolveCloudRuntimeConfig was zeroing cc.Token unconditionally before
reading the env var, so any token persisted in cloud.json was silently
discarded. Users running `engram sync --cloud` without ENGRAM_CLOUD_TOKEN
exported always received a 401 even when cloud.json held a valid token.

Remove the blanket zero assignment so the file token acts as a fallback
when the env var is absent. ENGRAM_CLOUD_TOKEN still takes precedence when
set. Update the test that locked in the old behaviour and add three new
tests that assert the fallback and the end-to-end Authorization header.

Closes #343
Copilot AI review requested due to automatic review settings May 27, 2026 15:12
@Alan-TheGentleman Alan-TheGentleman added the type:bug Bug fix label May 27, 2026
@Alan-TheGentleman Alan-TheGentleman merged commit ea9ec8c into main May 27, 2026
8 of 9 checks passed
@Alan-TheGentleman Alan-TheGentleman deleted the fix/sync-cloud-auth-header branch May 27, 2026 15:14
@Alan-TheGentleman Alan-TheGentleman review requested due to automatic review settings May 27, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cloud): client v1.15.9 sync --cloud does not send Authorization header despite valid cloud.json

1 participant