fix(security): replace openRouterImageApiKey with boolean flag in webview state#11400
fix(security): replace openRouterImageApiKey with boolean flag in webview state#114000xMink wants to merge 2 commits intoRooCodeInc:mainfrom
Conversation
All previously flagged issues have been addressed. No new issues found.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| if (prevState.openRouterImageApiKey !== apiKey) { | ||
| setChangeDetected(true) | ||
| } | ||
| const [pendingImageApiKey, setPendingImageApiKey] = useState<string | null>(null) |
There was a problem hiding this comment.
pendingImageApiKey is not reset when cachedState is reset elsewhere in this component. The useEffect hooks on lines 226 and 234 reset cachedState and clear changeDetected when the API config profile changes or settings are imported, but they don't call setPendingImageApiKey(null). If a user types an API key, then switches profiles (triggering the reset), and later saves another unrelated change, the stale pendingImageApiKey will be sent in the updateSettings payload, writing an unintended key.
| const [pendingImageApiKey, setPendingImageApiKey] = useState<string | null>(null) | |
| const [pendingImageApiKey, setPendingImageApiKey] = useState<string | null>(null) |
The fix itself is straightforward: add setPendingImageApiKey(null) alongside setChangeDetected(false) in both useEffect blocks (lines ~228 and ~235). I didn't include a multi-line suggestion since the affected lines are spread across non-contiguous blocks.
Fix it with Roo Code or mention @roomote and request a fix.
Closes #11399
Summary
getStateToPostToWebview()no longer includes the rawopenRouterImageApiKeystring. The webview receives onlyhasOpenRouterImageApiKey: boolean.getState()retains the raw key for extension-host consumers (GenerateImageTool).pendingImageApiKey(null= unchanged,""= clear,"abc"= set) prevents truthiness bugs when clearing the key.Test plan