Skip to content

feat: new export output format for dotenv eval's#281

Merged
varonix0 merged 1 commit into
mainfrom
daniel/new-export-output
Jun 25, 2026
Merged

feat: new export output format for dotenv eval's#281
varonix0 merged 1 commit into
mainfrom
daniel/new-export-output

Conversation

@varonix0

Copy link
Copy Markdown
Member

Description 📣

Added new dotenv-eval export format with POSIX shell-quoted values, safe for eval/source.

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

@infisical-review-police

Copy link
Copy Markdown

💬 Discussion in Slack: #pr-review-cli-281-feat-new-export-output-format-for-dotenv-eval-s

Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel.

@varonix0 varonix0 self-assigned this Jun 25, 2026
@varonix0 varonix0 requested a review from adilsitos June 25, 2026 14:29
@greptile-apps

greptile-apps Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces a new dotenv-eval export format that POSIX-quotes secret values via single-quoting with proper escape handling, making the output safe for eval "$(infisical export --format=dotenv-eval)" even when values contain single quotes, newlines, $, or backslashes.

  • Adds the FormatDotEnvEval constant, routing in formatEnvs, default filename/extension entries, and two new functions (formatAsDotEnvEval, posixShellQuote); the quoting logic is correct.
  • Adds thorough table-driven tests covering empty input, special characters, embedded quotes, and multiline values.
  • The doc comment on posixShellQuote mis-states the escape sequence used, and env.Key is not validated before interpolation into the eval-safe output — a key containing shell metacharacters would produce broken or dangerous export statements when eval'd.

Confidence Score: 4/5

The core quoting implementation is correct and well-tested; the two concerns are a misleading doc comment and a missing key-validation guard that would only matter if a stored key contained shell metacharacters.

The posixShellQuote function correctly escapes values, and the test suite exercises the important edge cases. The doc comment mis-labels the escape sequence, and env.Key is interpolated without a validity check — meaningful only if a key ever arrives with unexpected characters, but the format is explicitly designed for shell eval so the invariant should be enforced or documented.

The posixShellQuote comment and the key-handling path in formatAsDotEnvEval in packages/cmd/export.go deserve a second look before merge.

Important Files Changed

Filename Overview
packages/cmd/export.go Adds dotenv-eval format constant, routing, default filename/extension, and the formatAsDotEnvEval/posixShellQuote helpers; logic is correct but the posixShellQuote doc comment mis-states the escape sequence and the key is not validated before interpolation into the eval-safe output.
packages/cmd/export_test.go Adds well-structured table-driven tests for both formatAsDotEnvEval and posixShellQuote, covering edge cases (empty, multiline, embedded quotes, metacharacters); all assertions are correct.

Reviews (1): Last reviewed commit: "feat: new export output format for doten..." | Re-trigger Greptile

Comment thread packages/cmd/export.go
Comment thread packages/cmd/export.go
@varonix0 varonix0 merged commit 40242cc into main Jun 25, 2026
29 checks passed
pull Bot pushed a commit to soitun/infisical that referenced this pull request Jun 25, 2026
Document the new --format=dotenv-eval output added in Infisical/cli#281,
which emits POSIX shell-quoted `export KEY='value'` statements safe to
load via eval/source.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011qigV1v6yjb9Rh5JWXbsyD
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.

2 participants