fix(oauth): reject persisted profiles without access tokens#3180
Conversation
Tighten OpenAI OAuth token persistence and profile loading so blank or missing access tokens never replace the last known good token. Constraint: tinyhumansai#3130 reported OAuth profiles persisted without access_token Rejected: Failing the entire auth profile load | one corrupt OAuth profile should not block all profiles Confidence: high Scope-risk: narrow Directive: Keep OAuth token normalization and profile deserialization in sync for future OAuth providers Tested: GGML_NATIVE=OFF cargo test --manifest-path Cargo.toml --lib openhuman::inference::openai_oauth::tests::persist_openai_oauth_token_rejects_blank_access_token -- --exact --nocapture Tested: GGML_NATIVE=OFF cargo test --manifest-path Cargo.toml --lib openhuman::inference::openai_oauth::tests::lookup_openai_bearer_token_does_not_persist_blank_refreshed_access_token -- --exact --nocapture Refs: tinyhumansai#3130
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR hardens OAuth profile persistence by validating token data before storage and adds graceful recovery for any already-invalid profiles during load. Token normalization prevents persisting profiles with missing or empty ChangesOAuth Profile Validation and Recovery
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
well done friend |
Summary
access_tokenduring profile load instead of failing the whole auth profile set.src/openhuman/inference/openai_oauth/flow_tests.rsfor blank initial tokens and blank refresh responses.src/openhuman/credentials/profiles.rs,src/openhuman/inference/openai_oauth/store.rs,src/openhuman/inference/openai_oauth/flow_tests.rs.Problem
access_token.Solution
access_tokenvalues before writing them.access_token.Submission Checklist
diff-cover) meet the gate enforced by.github/workflows/pr-ci.yml. Runpnpm test:coverageandpnpm test:rustlocally; PRs below 80% on changed lines will not merge. — CI gate will enforce this; I ran focused Rust regressions locally in this environment.docs/TEST-COVERAGE-MATRIX.mdreflect this change (orN/A: behaviour-only change) — N/A: no feature rows were added, removed, or renamed; existing OAuth/token-storage rows already cover this surface.## Relateddocs/RELEASE-MANUAL-SMOKE.md) — N/A: root-Rust OAuth persistence fix only.Closes #NNNin the## RelatedsectionImpact
Related
AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
Commit & Branch
fix/oauth-profile-validationc20e456efd5a1e00cdcbdbcdff73454f968cac4cValidation Run
pnpm --filter openhuman-app format:check— passed in pre-push hook.pnpm typecheck— passed via the pre-pushcompilestep (tsc --noEmit).GGML_NATIVE=OFF cargo test --manifest-path Cargo.toml --lib openhuman::inference::openai_oauth::tests::persist_openai_oauth_token_rejects_blank_access_token -- --exact --nocapture;GGML_NATIVE=OFF cargo test --manifest-path Cargo.toml --lib openhuman::inference::openai_oauth::tests::lookup_openai_bearer_token_does_not_persist_blank_refreshed_access_token -- --exact --nocapturecargo fmt --manifest-path Cargo.toml --all --check;GGML_NATIVE=OFF cargo check --manifest-path Cargo.tomlapp/src-taurifiles changed.Validation Blocked
command:pnpm rust:check(pre-push hook path:cargo check --manifest-path src-tauri/Cargo.toml)error:failed to load source for dependency 'tauri'because/Users/idah/projects/openhuman/app/src-tauri/vendor/tauri-cef/crates/tauri/Cargo.tomlis missing in this local environment.impact:push required--no-verify; no Tauri-shell files were changed in this PR.Behavior Changes
Parity Contract
Duplicate / Superseded PR Handling
fix/oauth-profile-validation.Summary by CodeRabbit
Bug Fixes
Tests