Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 21, 2025

Problem

The crumb export command was not exporting environment variables when the env section in .crumb.yaml contained literal values. For example, with this configuration:

version: "1.0"
environments:
  live:
    path: "/contacts/live"
    remap:
      JWT_KEY: "CONTACTS_JWT_KEY"
      JWT_KEY_STATIC: "CONTACTS_JWT_KEY_STATIC"
      DB_DSN: "CONTACTS_DB_DSN"
    env:
      DB_TYPE: "postgres"

Running crumb export --env live would not export DB_TYPE, even though it's defined in the env section.

Root Cause

The export command treated all values in the env section as paths to secrets in the encrypted storage. When it encountered DB_TYPE: "postgres", it tried to look up a secret at the path "postgres" (which doesn't exist), and silently skipped it when the lookup failed.

Solution

Modified the export command to distinguish between two types of values in the env section:

  • Path-based values (starting with /) - looked up in encrypted secrets storage (existing behavior)
  • Literal values (not starting with /) - used directly as-is (new behavior)

This allows .crumb.yaml to specify both:

  • Static configuration values that don't need encryption (DB_TYPE: "postgres")
  • References to encrypted secrets (SECRET_KEY: "/contacts/live/secret")

Example

With the fix, the same configuration now exports correctly:

$ crumb export --env live
# Exported from /contacts/live (environment: live)
export CONTACTS_DB_DSN=postgres://user:pass@localhost/livedb
export CONTACTS_JWT_KEY=live-jwt-secret
export CONTACTS_JWT_KEY_STATIC=live-jwt-static-secret
export DB_TYPE=postgres  # ✅ Now exported!

Changes

  • Updated ExportCommand in pkg/commands/commands.go to check if env values start with /
  • Added comprehensive test coverage in TestExportCommandLiteralEnvValues
  • All existing tests continue to pass (no breaking changes)

Testing

  • ✅ All existing tests pass
  • ✅ New tests validate both literal and path-based env values
  • ✅ Manually verified with the exact scenario from the issue
  • ✅ CodeQL security scan: 0 alerts

Fixes #[issue-number]

Original prompt

This section details on the original issue you should resolve

<issue_title>Crumb export command is not using env key</issue_title>
<issue_description>With a config file like below, when running crumb export --env live the DB_TYPE is not being exported

version: "1.0"
environments:
default:
path: ""
remap: {}
env: {}
live:
path: "/contacts/live"
remap: {
JWT_KEY : "CONTACTS_JWT_KEY",
JWT_KEY_STATIC: "CONTACTS_JWT_KEY_STATIC",
DB_DSN : "CONTACTS_DB_DSN"
}
env: {
DB_TYPE: "postgres"
}
</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #12


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix crumb export command to use env key Fix export command to support literal values in env section Oct 21, 2025
Copilot AI requested a review from crhuber October 21, 2025 16:21
Copilot finished work on behalf of crhuber October 21, 2025 16:21
@crhuber crhuber marked this pull request as ready for review October 21, 2025 16:24
@crhuber crhuber merged commit ade68cf into main Oct 21, 2025
4 checks passed
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.

Crumb export command is not using env key

2 participants