Backfill Reddit credentials from X-Apollo-Reddit-* headers on account upserts - #12
Merged
Conversation
… upserts The tweak's JSON body augmentation can't reach bodies attached to upload/data tasks via fromData:, so registrations can arrive without reddit_client_id and 422 even though the user has an API key set. The tweak now also sends its global-default credentials as X-Apollo-Reddit-* headers (same pattern as X-Apollo-Transport on /v1/device); backfill missing fields from them, between body fields and the env-var fallback (body > header > env). Also give the singular upsert handler the same defensive missing-credentials 422 the bulk handler has — registerAccount's NewAuthenticatedClient panics on empty tokens.
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.
Problem
Account upserts can arrive without
reddit_client_id(422missing required credentials,has_client_id: false) even when the user has an API key configured: the tweak's NSData-based body augmentation can't reach bodies attached to upload/data tasks viafromData:, so Apollo's raw payload — which never carried thereddit_*fields — hits the wire unmodified. The existingREDDIT_CLIENT_IDenv fallback only helps deployments whose users all share that one key.Fix
X-Apollo-Reddit-Client-Id/-Client-Secret/-Redirect-Uri/-User-Agentheaders on every account upsert (companion PR: Notifications: carry Reddit credentials in headers on account upserts Apollo-Reborn#642 — same pattern asX-Apollo-Transporton/v1/device). Backfill missing fields from those headers in both upsert handlers, between body fields and the env fallback: body > header > env, so per-account overrides in an augmented body still win.registerAccount→NewAuthenticatedClientpanics on empty tokens, and unaugmented singular upserts hit exactly that path.Testing
go build ./...andgo vet ./internal/api/clean.