+
Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 9, 2025

The get command with --export flag was incorrectly using the full path to generate environment variable names instead of just the final segment. This caused confusing export statements where the variable name included the entire path hierarchy.

Problem

When running:

crumb get /foo/live/DB_DSN --export

The output was:

export FOO_LIVE_DB_DSN="value"

But users expect:

export DB_DSN="value"

Root Cause

The ExtractVarName function in /pkg/storage/storage.go was converting the entire path to an environment variable name by replacing all slashes with underscores, rather than extracting only the final path segment like the existing ConvertPathToEnvVar function used by the export command.

Solution

Modified ExtractVarName to:

  1. Split the path by / separators
  2. Extract only the last segment (the actual secret name)
  3. Apply the same sanitization rules (uppercase, replace dashes with underscores)

This makes the behavior consistent between get --export and the standalone export command.

Testing

  • Added comprehensive test coverage for ExtractVarName with various path formats
  • Verified both bash and fish shell export formats work correctly
  • All existing tests continue to pass
  • Manual testing confirms the fix resolves the reported issue

Fixes #6.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Contributor Author

Copilot AI commented Sep 9, 2025

@crhuber 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI and others added 2 commits September 9, 2025 12:17
…mand

Co-authored-by: crhuber <5857391+crhuber@users.noreply.github.com>
Co-authored-by: crhuber <5857391+crhuber@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] get command with --export is appending full path Fix get command --export to use only last path segment as variable name Sep 9, 2025
@Copilot Copilot AI requested a review from crhuber September 9, 2025 12:20
Copilot finished work on behalf of crhuber September 9, 2025 12:20
@crhuber crhuber marked this pull request as ready for review September 9, 2025 12:29
@crhuber crhuber merged commit 4469454 into main Sep 9, 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.

get command with --export is appending full path

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载