Skip to content

feat: support multiple --path values in export command - #388

Open
mateuscmtropical wants to merge 1 commit into
Infisical:mainfrom
mateuscmtropical:feature/export-multi-path-v2
Open

feat: support multiple --path values in export command#388
mateuscmtropical wants to merge 1 commit into
Infisical:mainfrom
mateuscmtropical:feature/export-multi-path-v2

Conversation

@mateuscmtropical

@mateuscmtropical mateuscmtropical commented Sep 4, 2026

Copy link
Copy Markdown

Description 📣

Implements #900 (specify multiple paths in the CLI).

run already supported multiple --path flags. export only took one. This brings export up to the same behavior:

  • --path is now a StringArray, matching run's existing flag
  • reuses run's fetchSecrets to fetch secrets from each path
  • merges duplicate keys across paths (last path wins)
  • tag filtering now happens once, client-side, after the merge, instead of being applied per-path on the server — otherwise a tagged value from an earlier path could survive over a later path's untagged override
  • fixed a related bug in error handling: wrapped API errors weren't unwrapped before the pretty-print check, so failures showed a generic error instead of the formatted one

Type ✨

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

Tests 🛠️

Ran go test ./packages/cmd/... -vet=off -count=2 (all passing).

Also tested manually against a real Infisical Cloud project: created two folders with overlapping and non-overlapping secret keys, some tagged and some not, and confirmed:

infisical export --env=dev --path=/foo --path=/bar
infisical export --env=dev --path=/foo --path=/bar --tags=backend

both return the expected merged/filtered result (last path wins on key collisions, tag filtering applied after merge).


@infisical-cla-app

infisical-cla-app Bot commented Sep 4, 2026

Copy link
Copy Markdown

CLA satisfied. All contributors have signed the current CLA. The cla/signed check is passing.

@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extends export to accept repeated --path flags while preserving deterministic last-path-wins behavior.

  • Reuses the existing sequential multi-path secret-fetching helper.
  • Merges duplicate keys before applying client-side tag filtering and sorting.
  • Recognizes wrapped API errors for formatted error output.
  • Adds unit coverage for repeated path flags, duplicate-key precedence, and merge-before-filter behavior.

Confidence Score: 5/5

The PR appears safe to merge with no actionable failures identified.

Path retrieval remains sequential and ordered, authentication and request options are preserved, wrapped API errors are handled safely, and user-provided paths cannot alter the HTTP destination.

Important Files Changed

Filename Overview
packages/cmd/export.go Adds repeatable paths, ordered secret merging, and post-merge tag filtering without an established correctness or SSRF issue.
packages/cmd/export_test.go Covers repeatable flag behavior, last-value precedence, sorting, and tag filtering after duplicate resolution.
packages/util/log.go Uses errors.As so wrapped API errors continue through the existing formatted-error path.

Reviews (1): Last reviewed commit: "cli: support multiple --path values in e..." | Re-trigger Greptile

@mateuscmtropical mateuscmtropical changed the title cli: support multiple --path values in export command feat: support multiple --path values in export command Sep 4, 2026
`run` already supported multiple `--path` flags. `export` only took one.
This brings `export` up to the same behavior: `--path` is now a
StringArray (matching run.go), reuses run.go's fetchSecrets to fetch
secrets from each path, and merges duplicate keys across paths
(last path wins).

Tag filtering now happens once, client-side, after the merge, instead
of being applied per-path on the server -- otherwise a tagged value
from an earlier path could survive over a later path's untagged
override.

Also fixes a related bug in error handling: wrapped API errors weren't
unwrapped before the pretty-print check in PrintErrorAndExit, so
failures showed a generic error instead of the formatted one.

Closes Infisical/infisical#900
@mateuscmtropical
mateuscmtropical force-pushed the feature/export-multi-path-v2 branch from 46af36f to 6e30b6b Compare September 4, 2026 23:24
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