Fix: Support camelCase keyPassword in JSON host import #384
Reference in New Issue
Block a user
Delete Branch "fix/keypassword-import-camelcase"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fix: Support camelCase
keyPasswordin JSON host importSummary
Fixed the bulk import endpoint to properly accept
keyPassword(camelCase) field from JSON imports, resolving authentication failures with encrypted SSH private keys.Problem
When importing SSH host configurations from JSON with encrypted private keys, the
keyPasswordfield was not being saved to the database. This caused the error:The issue occurred because:
keyPassword(camelCase)key_password(snake_case)nullin the databaseSolution
Updated the bulk import endpoint (
/ssh/bulk-import) insrc/backend/database/routes/ssh.tsto acceptkeyPasswordin camelCase format, which is consistent with:Changes Made
File:
src/backend/database/routes/ssh.ts(Line ~1415)Before:
After:
Testing
The fix ensures that JSON imports with the following structure work correctly:
Impact
Related Issues
Checklist
Summary of Changes
Hello @thorved, I'm Gemini Code Assist1 ! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This PR addresses a bug in the SSH host bulk import functionality where encrypted private key passwords (
keyPassword) were not being correctly recognized from JSON input due to a camelCase vs. snake_case mismatch. The fix updates thessh.tsroute to correctly parse thekeyPasswordfield, resolving authentication failures and ensuring consistency with the application's naming conventions and JSON export format.Highlights
keyPasswordfield was not correctly processed during JSON host imports, leading to authentication failures for SSH hosts with encrypted private keys. The intent is to align the bulk import endpoint with the camelCase naming convention used elsewhere in the application and in JSON exports.src/backend/database/routes/ssh.ts. Specifically, the logic for assigning thekey_passwordfield during bulk import was updated. It now directly useshostData.keyPassword(camelCase) instead ofhostData.key_password(snake_case) whenauthTypeis 'key'. This ensures that the password for encrypted SSH keys is correctly saved from JSON imports.Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point by creating a comment using either
/gemini <command>or@gemini-code-assist <command>. Below is a summary of the supported commands on the current page./gemini review/gemini summary/gemini helpCustomization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a
.gemini/folder in the base of the repository. Detailed instructions can be found here.Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩︎
Code Review
Thank you for this contribution. The fix correctly addresses the issue with
keyPasswordin bulk imports. I've added one suggestion to improve backward compatibility and make the API more robust. Please take a look.@@ -1414,3 +1414,3 @@key_password:hostData.authType === "key" ? hostData.key_password : null,hostData.authType === "key" ? hostData.keyPassword : null,keyType:While this change correctly adds support for
keyPassword, it removes the existing support forkey_password. This could be a breaking change for any clients that might be using the snake_case version.To ensure backward compatibility and make the API more robust, it would be better to support both formats. You can achieve this by checking for
keyPasswordfirst and then falling back tokey_passwordif the former is not present. This approach is also used elsewhere in the codebase (e.g., inresolveHostCredentials).@@ -1414,3 +1414,3 @@key_password:hostData.authType === "key" ? hostData.key_password : null,hostData.authType === "key" ? hostData.keyPassword : null,keyType:Before:
After:
The fix ensures that JSON imports with the following structure work correctly: