Skip to content

Studio: persist provider and Hugging Face credentials - #8299

Merged
wasimysaid merged 10 commits into
unslothai:mainfrom
wasimysaid:feat/persist-studio-credentials
Aug 11, 2026
Merged

wasimysaid merged 10 commits into
unslothai:mainfrom
wasimysaid:feat/persist-studio-credentials

Conversation

@wasimysaid

Copy link
Copy Markdown
Collaborator

Summary

  • persist external provider API keys and Hugging Face tokens in studio.db
  • encrypt saved credentials with AES-GCM using an installation key stored separately in auth.db
  • migrate legacy browser credentials server-first without deleting plaintext until persistence is confirmed
  • hydrate credentials at authenticated bootstrap and keep reconciliation safe across logout/re-authentication
  • use saved provider keys for connection tests, model discovery, chat, and OpenAI containers while preserving explicit-key compatibility
  • support explicit saved-key removal and idempotent provider/HF cleanup

Upgrade safety

  • additive SQLite schema and optional API fields
  • repeated startup, upsert, clear, delete, and migration operations are idempotent
  • legacy credentials remain available as fallback when migration fails
  • password changes and unsloth studio reset-password preserve credential decryptability
  • saved credentials are bound to their persisted provider endpoint rather than request-controlled routing metadata

Validation

  • frontend TypeScript typecheck
  • all 1,508 frontend Node tests
  • 15 focused backend credential/auth/provider/chat/container tests
  • Python compilation and git diff --check
  • isolated UNSLOTH_STUDIO_HOME install/update/restart smoke test with Playwright
  • legacy localStorage migration and repeated-bootstrap idempotency verification

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab8ad94d90

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 10, 2026
@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: a037a21747

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a23b9b77dd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread studio/backend/routes/settings.py Resolved
Comment thread studio/backend/routes/providers.py Resolved
@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d04520d59c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread studio/backend/routes/inference.py Resolved
Comment thread studio/backend/routes/inference.py Resolved
@BardiaKoopah

Copy link
Copy Markdown
Contributor

I ran the credential encryption rather than reading it, with UNSLOTH_STUDIO_HOME pointed at a scratch directory, exercising storage/credential_secrets.py directly. Four properties I wanted to watch hold:

round trip                                        OK
25 writes of identical plaintext                  25/25 distinct nonces
ciphertext row moved from openai to anthropic     returns None
one ciphertext byte flipped                       returns None

Same numbers on a second run against a fresh store. The row-swap case is the one I expected to slip through, and the kind/scope binding in _associated_data catches it. Both failure paths return None and log "Saved credential is unreadable; re-entry is required" instead of raising, so a corrupted row degrades to "not configured" rather than failing the request.

I also went looking for whatever would break decryptability across a password reset. Nothing under studio/backend unlinks auth.db, so credential_encryption_key_v1 in app_secrets outlives a reset. That one is a grep, not a run.

CredentialBootstrapGate I looked at twice, because gating the tree on hasAuthToken() looked like it would strand a fresh install on RouteFallback. It doesn't: auth-flow routes bypass the gate, and the one route explicitly opted back in, /onboarding, carries beforeLoad: () => requireAuth(), so there's always a token by then.

Frontend on d04520d59:

npm test                    1516 passed
npm run typecheck           clean
npm run build               clean
npm run i18n:check:strict   clean

Merge base 871e4ab3e gives 1497, so this adds 19. Your description says 1,508, which I assume is an earlier push.

Two things I'd rather flag as unchecked than let read as fine. I couldn't run the backend suite at all, no pytest deps on this box, so your 15 focused backend tests are unverified by me. And I drove credential_secrets.py directly rather than through routes/provider_credentials.py, so nothing I did touches the authz on the new endpoints.

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 426cd54eb5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8aace75e4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 011ec963fb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@wasimysaid
wasimysaid merged commit 19abc08 into unslothai:main Aug 11, 2026
43 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants