Skip to content

feat: implement JSON import functionality for secrets#7

Merged
TarasKovalenko merged 3 commits intomainfrom
Taras/import-from-json
Feb 27, 2026
Merged

feat: implement JSON import functionality for secrets#7
TarasKovalenko merged 3 commits intomainfrom
Taras/import-from-json

Conversation

@TarasKovalenko
Copy link
Owner

#5

@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 pull request introduces a significant new feature allowing users to import secrets into the application from a JSON file. This streamlines the process of adding multiple secrets, enhancing efficiency and user experience. The implementation includes robust validation to ensure data integrity during import and provides clear guidance on the expected JSON structure. Additionally, a refinement was made to the secret value display logic to improve reliability when navigating between secrets.

Highlights

  • JSON Import Functionality: Implemented the ability to import secrets from a JSON file, supporting two distinct formats: an array of secret objects or an object containing a 'secrets' array. This feature is accessible via a new 'Import JSON' button in the Secrets toolbar and a command palette entry.
  • Robust Input Validation: Added comprehensive validation for imported secrets, ensuring that 'name' and 'value' fields are present and correctly formatted. It also validates 'contentType', 'enabled' status, 'expires' and 'notBefore' date strings, and 'tags' structure, providing clear error messages for invalid inputs.
  • Improved Secret Value Fetching: Refactored the secret value fetching mechanism to prevent race conditions. This ensures that when users rapidly switch between secrets, only the value for the currently selected secret is displayed, avoiding stale data issues.
  • Documentation and Examples: Updated the README.md to include detailed instructions on how to use the new JSON import feature, outlining accepted formats and validation rules. A new example JSON file (examples/secrets-import.example.json) was added to demonstrate the expected structure.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • README.md
    • Updated the features list to include 'Import secrets from JSON file'.
    • Added a new section detailing the usage, accepted formats, and validation rules for importing secrets from JSON.
  • examples/secrets-import.example.json
    • Added a new example JSON file demonstrating the structure for importing secrets.
  • src/components/command-palette/CommandPalette.tsx
    • Added a new command palette entry 'Import Secrets from JSON' to trigger the import process.
  • src/components/secrets/RevealSecretValue.tsx
    • Imported useEffect and useRef hooks.
    • Introduced a fetchRequestIdRef to manage concurrent fetch requests.
    • Implemented logic to prevent race conditions when fetching secret values, ensuring only the latest request's result is processed.
    • Added a useEffect hook to reset sensitive UI state when the selected secret changes.
  • src/components/secrets/SecretsList.tsx
    • Imported ChangeEvent, useRef, and setSecret from tauri.
    • Imported parseSecretsImportJson utility.
    • Added state variables for import messages, loading status, and a ref for the hidden file input.
    • Implemented a useEffect hook to clear import messages after a timeout.
    • Added an event listener for azv:import-secrets to trigger the file input click from the command palette.
    • Created handleImportButtonClick to programmatically trigger the hidden file input.
    • Developed handleImportFromFile to process the selected JSON file, parse its content, validate secrets, and call setSecret for each item, handling success and failure states.
    • Added a hidden file input element to the UI for selecting JSON files.
    • Integrated an 'Import JSON' button into the toolbar, enabling the import process and displaying loading state.
    • Disabled the 'New' button during import operations.
    • Added a UI element to display import success or error messages.
  • src/components/secrets/secretsImport.test.ts
    • Added a new test file for secretsImport utility.
    • Included tests for parsing secrets in array format.
    • Included tests for parsing secrets in envelope format (object with 'secrets' array).
    • Added tests to verify rejection of invalid secret names and tags.
  • src/components/secrets/secretsImport.ts
    • Added a new utility file containing parseSecretsImportJson function.
    • Defined interfaces for raw import items and the import envelope.
    • Implemented helper functions isObject, parseDateField, and parseTags for robust data validation.
    • Created normalizeItems to handle both array and envelope JSON structures.
    • Developed parseItem to validate individual secret properties like name, value, content type, enabled status, dates, and tags.
    • Exported parseSecretsImportJson to parse and validate the entire JSON input, returning an array of CreateSecretRequest objects.
Activity
  • The pull request description links to issue Import from JSON #5, indicating the context for this feature. No other human activity (comments, reviews) was provided in the context.
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.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

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.

Footnotes

  1. 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces a new feature to import secrets from a JSON file, enhancing the application's functionality. The implementation includes robust JSON parsing and validation logic, comprehensive error handling, and appropriate UI feedback. The changes also incorporate important state management improvements to prevent race conditions and ensure sensitive UI data is cleared correctly when switching secrets. Documentation in README.md and example files are updated to reflect the new feature, and unit tests are added for the import parsing logic.

@TarasKovalenko TarasKovalenko merged commit 1da569f into main Feb 27, 2026
3 checks passed
@TarasKovalenko TarasKovalenko deleted the Taras/import-from-json branch February 27, 2026 09:00
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.

1 participant