Skip to content

Subscription registration fails silently when CREDENTIAL_ENCRYPTION_KEY is not set #148

Closed

Description

@AndriiPasternak31

Summary

When a user tries to register a Claude subscription in Settings → Claude Subscriptions, the UI does nothing — no error message, no feedback, no loading state change. The subscription simply doesn't appear in the table.

Root Cause

Two issues combine to create this silent failure:

1. Backend returns an error, frontend doesn't show it

The backend correctly rejects the request with a 500 error:

{"detail": "Encryption key not configured. Set CREDENTIAL_ENCRYPTION_KEY environment variable with a 32-byte hex string (64 characters). Generate with: python -c \"import secrets; print(secrets.token_hex(32))\""}

But the frontend's addSubscription() function in src/frontend/src/views/Settings.vue catches the error and sets error.value, which may not be visible to the user depending on scroll position or rendering. There's no toast/notification for this failure — it just silently fails.

2. No setup validation or user guidance

CREDENTIAL_ENCRYPTION_KEY is required for any credential/subscription storage but:

  • It's not set by default in .env.example or generated during setup
  • The Settings page doesn't check whether encryption is configured before showing the subscription form
  • A new Trinity deployment will always hit this issue when trying subscriptions for the first time

Steps to Reproduce

  1. Fresh Trinity deployment (or any deployment without CREDENTIAL_ENCRYPTION_KEY in .env)
  2. Go to Settings → Claude Subscriptions
  3. Fill in Name, Type, and paste a valid token (starting with sk-ant-oat01-)
  4. Click Register Subscription
  5. Nothing happens — no error shown, no subscription created

Expected Behavior

Either:

  • Option A: Show the backend's error message to the user ("Encryption key not configured...") with instructions on how to fix it
  • Option B: Detect missing encryption key on the Settings page load and show a setup banner before the subscription form
  • Option C: Auto-generate the key during start.sh if not set (similar to how SECRET_KEY could be handled)

Relevant Code

  • Frontend: src/frontend/src/views/Settings.vue — addSubscription() function (around line 1857)
  • Backend: The subscription creation endpoint at POST /api/subscriptions — encryption key check
  • Config: docker-compose.yml line 41 — CREDENTIAL_ENCRYPTION_KEY=${CREDENTIAL_ENCRYPTION_KEY:-} (defaults to empty)

Workaround

Add to .env:

CREDENTIAL_ENCRYPTION_KEY=$(python3 -c "import secrets; print(secrets.token_hex(32))")

Then recreate the backend container:

docker-compose up -d backend

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions