Skip to content

cli: support multiple --path values in export command - #387

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

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

Conversation

@mateuscmtropical

@mateuscmtropical mateuscmtropical commented Sep 4, 2026

Copy link
Copy Markdown

This 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

Tested manually against a real project (multiple folders, with and without tag filtering) and with go test ./packages/cmd/... -count=2.

Closes Infisical/infisical#900

Student contribution for a free software course. Feedback welcome.

@infisical-cla-app

Copy link
Copy Markdown

📝 Contributor License Agreement required

Before this PR can merge, every contributor must sign the Infisical CLA.
Signing is quick: sign in with GitHub, review the CLA, and accept.

👉 Sign the CLA

Still needs to sign:

Once everyone has signed, the check updates automatically — no need to close and reopen the PR.

@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes export --path repeatable, fetches each requested path through the shared multi-path helper, deterministically applies last-path-wins merging before client-side tag filtering, and improves formatting of wrapped API errors.

  • Preserves the existing default root-path behavior while accepting repeated path flags.
  • Sorts merged secrets for deterministic export output.
  • Adds focused tests for duplicate-key precedence, post-merge tag filtering, and repeatable flag parsing.
  • No SSRF path was identified: supplied secret paths remain query parameters and cannot select the request host.

Confidence Score: 5/5

The PR appears safe to merge; the multi-path ordering, filtering, authentication, and wrapped-error behavior are consistent with the intended export contract.

No actionable failures remain: paths are fetched sequentially in user-supplied order, same-path import precedence is resolved before merging, output is filtered and sorted, and path values do not influence the API host.

Important Files Changed

Filename Overview
packages/cmd/export.go Adds repeatable path handling and deterministic last-path-wins merging before tag filtering and formatting.
packages/cmd/export_test.go Adds focused coverage for merging, tag precedence, deterministic ordering, and repeated StringArray flag values.
packages/util/log.go Uses errors.As so wrapped API errors retain specialized user-facing formatting.

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

`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 branch from 1c4eacd to 43a5d3a Compare September 4, 2026 23:12
@mateuscmtropical

Copy link
Copy Markdown
Author

Closing in favor of a fresh PR from a clean branch.

@mateuscmtropical
mateuscmtropical deleted the feature/export-multi-path branch September 4, 2026 23:13
@mateuscmtropical

Copy link
Copy Markdown
Author

Superseded by #388.

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.

Specify multiple paths in the CLI

1 participant