Menu ▾ ▴

#18 [Feature]: Support dotenv, JSON, and YAML secret import and export

closed
nobody
2026-09-12
2026-09-11
Anonymous
No

Originally created by: thomijasir
Originally owned by: thomijasir

Feature description

Let users move secret sets through dotenv, JSON, or YAML files and standard input. Apply the same input support when initializing a project.

Current behavior

Import and init read dotenv files. Export writes dotenv to a file or stdout.

Why we need this

Deployment tools and existing applications commonly exchange flat configuration as JSON or YAML. Manual conversion adds scripts that can mishandle quoting or expose values.

CLI interface

  • dopbase init storefront development --from .env
  • dopbase init storefront development --from secrets.json
  • dopbase init storefront development --from - --format yaml
  • dopbase import ENVIRONMENT secrets.json --format json
  • dopbase import ENVIRONMENT - --format yaml
  • dopbase export ENVIRONMENT --output secrets.yaml --format yaml
  • dopbase export ENVIRONMENT --stdout --format json

--format <dotenv|json|yaml> is optional for files and overrides filename inference. It is required when init or import reads - from stdin.

Expected behavior

  • Infer JSON from .json and YAML from .yaml or .yml, case-insensitively.
  • Treat every other filename as dotenv. This preserves .env, .env.production, and extensionless dotenv files.
  • Keep dotenv as the default stdout export format.
  • Accept only one flat mapping of string keys to string values for JSON and YAML.
  • Reject nested objects, arrays, numbers, booleans, null values, duplicate keys, empty keys, multiple YAML documents, and inputs with no secret entries.
  • Continue accepting empty string values such as KEY= or {"KEY":""}.
  • Sort keys for deterministic dotenv, JSON, and YAML output.
  • Preserve import dry runs, replacement previews, confirmations, and expected-revision checks.
  • Preserve password confirmation for plaintext export and private file permissions.

Security and compatibility

  • Never include secret values in validation errors, progress messages, or logs. An error may identify the affected key and value type.
  • Keep global --json separate from secret serialization. Continue rejecting global --json with plaintext --stdout.
  • Do not overwrite an output file without --force.
  • Stdin import and init require an existing valid login or DOPBASE_TOKEN because stdin is carrying secret data and cannot also serve an interactive login prompt.
  • Keep server request and response schemas unchanged. Format parsing and rendering belong to the CLI.

Out of scope

  • Adding JSON or YAML import and export to the Admin UI.
  • Framework-specific formats.
  • Template rendering.
  • Changing server request or response schemas.

Acceptance criteria

  • [ ] Init, import, and export support dotenv, JSON, and YAML files.
  • [ ] Init and import accept stdin only with an explicit format.
  • [ ] Explicit formats override filename inference.
  • [ ] .env.production and unknown extensions remain compatible as dotenv.
  • [ ] All three formats export deterministic content.
  • [ ] Invalid value types identify the affected key without printing its value.
  • [ ] Inputs with no entries are rejected, while empty string values remain valid.
  • [ ] Existing dotenv commands remain compatible.
  • [ ] Dry-run and replacement safety work for every input format.
  • [ ] File exports retain overwrite protection and private permissions.

Test scenarios

Add format and round-trip tests under app/tests/cli/. Cover init and import arguments, stdin requirements, malformed documents, duplicate and empty keys, unsupported types, zero-entry input, extension inference, format overrides, output ordering, overwrite protection, and errors that do not expose secret values.

Documentation

Document supported shapes, init and import stdin usage, format inference, .env.production compatibility, plaintext handling, deterministic output, and pipeline examples. Make it clear that the Admin UI remains dotenv-only.

Dependencies

Use serde-saphyr with strict duplicate-key, merge-key, type, and parser-budget settings for YAML.

Related

Tickets: #23
Tickets: #42

Discussion

  • Anonymous

    Anonymous - 2026-09-11
     
  • Anonymous

    Anonymous - 2026-09-12

    Originally posted by: thomijasir

    Implemented in [#42].

    The pull request adds the shared CLI format layer, wires it into init, import, and export, and includes parser, argument, and end-to-end command tests. The server request and response schemas are unchanged.

    Verification passed:

    • Cargo formatting check
    • Clippy with warnings denied across all targets and features
    • Full locked Rust test suite, including 100 CLI tests
    • Documentation build
    • CodeGraph sync
     

    Related

    Tickets: #42

  • Anonymous

    Anonymous - 2026-09-12

    Ticket changed by: dopbase

    • status: open --> closed
     

Log in to post a comment.