• Will Chen's avatar
    fix: trim whitespace from API keys and secrets in encrypt/decrypt (#2518) · 26687a6f
    Will Chen 提交于
    ## Summary
    - Trims whitespace from API keys and secrets during both encryption and
    decryption in `src/main/settings.ts`
    - Prevents issues caused by accidental leading/trailing whitespace or
    newlines in API keys (e.g., from copy-paste)
    - Adds comprehensive tests for the `encrypt`, `decrypt`, and
    `readSettings` whitespace trimming behavior
    
    ## Test plan
    - [x] Unit tests added for `encrypt()` trimming whitespace before
    encrypting
    - [x] Unit tests added for `decrypt()` trimming whitespace from both
    plaintext and electron-safe-storage secrets
    - [x] Unit tests added for `readSettings()` trimming whitespace from
    decrypted API keys
    - [x] All 784 existing tests pass
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    <!-- devin-review-badge-begin -->
    
    ---
    
    <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2518"
    target="_blank">
      <picture>
    <source media="(prefers-color-scheme: dark)"
    srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
    <img
    src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1"
    alt="Open with Devin">
      </picture>
    </a>
    <!-- devin-review-badge-end -->
    
    <!-- CURSOR_SUMMARY -->
    ---
    
    > [!NOTE]
    > <sup>[Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) is
    generating a summary for commit
    d24002f59f18428d78ce55d11e82d4800425d3eb. Configure
    [here](https://cursor.com/dashboard?tab=bugbot).</sup>
    <!-- /CURSOR_SUMMARY -->
    
    <!-- This is an auto-generated description by cubic. -->
    ---
    ## Summary by cubic
    Trim whitespace from API keys and secrets during encryption, decryption,
    and settings reads to prevent auth failures from copy‑pasted spaces or
    newlines. Ensures consistent storage and use of secrets across
    providers.
    
    - **Bug Fixes**
      - encrypt(): trims input before encrypting or storing plaintext
    - decrypt(): trims decrypted strings for both electron-safe-storage and
    plaintext
    - readSettings(): trims whitespace from decrypted and plaintext secrets
    - Added unit tests for encrypt, decrypt, and readSettings trimming
    behavior
    
    <sup>Written for commit d24002f59f18428d78ce55d11e82d4800425d3eb.
    Summary will update on new commits.</sup>
    
    <!-- End of auto-generated description by cubic. -->
    Co-authored-by: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
    26687a6f
名称
最后提交
最后更新
..
__snapshots__ 正在载入提交数据...
README.md 正在载入提交数据...
ai_messages_cleanup.test.ts 正在载入提交数据...
ai_messages_utils.test.ts 正在载入提交数据...
app_env_vars_utils.test.ts 正在载入提交数据...
chat_stream_handlers.test.ts 正在载入提交数据...
cleanFullResponse.test.ts 正在载入提交数据...
compaction_storage.test.ts 正在载入提交数据...
compaction_utils.test.ts 正在载入提交数据...
formatMessagesForSummary.test.ts 正在载入提交数据...
github_utils.test.ts 正在载入提交数据...
local_agent_handler.test.ts 正在载入提交数据...
local_agent_list_files_path_safety.test.ts 正在载入提交数据...
mcp_tool_utils.test.ts 正在载入提交数据...
mention_apps.test.ts 正在载入提交数据...
parseOllamaHost.test.ts 正在载入提交数据...
path_utils.test.ts 正在载入提交数据...
prepare_step_utils.test.ts 正在载入提交数据...
problem_prompt.test.ts 正在载入提交数据...
readSettings.test.ts 正在载入提交数据...
replacePromptReference.test.ts 正在载入提交数据...
retryWithRateLimit.test.ts 正在载入提交数据...
style-utils.test.ts 正在载入提交数据...
supabase_utils.test.ts 正在载入提交数据...
versioned_codebase_context.test.ts 正在载入提交数据...
xmlEscape.test.ts 正在载入提交数据...