fix: include type field in encrypted set-default values#82
Merged
Conversation
When using `set-default --secret`, encrypted values were missing the
required `type` field in the API payload, causing the value and type
to not be sent to the server.
Changes:
- Fix encryption.ts to use `value` field instead of `string`
- Add `type: 'string'` to encrypted values in set-default.ts
- Add test validation for encrypted value structure
- Bump version to 0.0.12
Before (incorrect payload):
```json
{
"value": {
"string": "encrypted-data",
"confidential": true,
"decryptWith": "reforge.secrets.encryption.key"
}
}
```
After (correct payload):
```json
{
"value": {
"type": "string",
"value": "encrypted-data",
"confidential": true,
"decryptWith": "reforge.secrets.encryption.key"
}
}
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where
set-default --secretwas not sending thetypefield and was using the wrong field name for encrypted values, causing the value to not be properly sent to the server.Problem
When setting encrypted values using
reforge set-default --secret, the API payload was malformed:typefieldstringas the field name instead ofvalueThis caused encrypted values to fail when sent to the
/internal/ops/v1/set-defaultendpoint.Solution
stringtovaluetype: 'string'field to encrypted valuesPayload Comparison
Before (Incorrect) ❌
{ "configKey": "test.secret", "currentVersionId": 1, "environmentId": 5, "value": { "string": "encrypted-data--iv--tag", "confidential": true, "decryptWith": "reforge.secrets.encryption.key" } }After (Correct) ✅
{ "configKey": "test.secret", "currentVersionId": 1, "environmentId": 5, "value": { "type": "string", "value": "encrypted-data--iv--tag", "confidential": true, "decryptWith": "reforge.secrets.encryption.key" } }Files Changed
src/util/encryption.ts- Fixed encrypted value field namesrc/commands/set-default.ts- Added type field to encrypted valuestest/responses/set-default.ts- Added validation for encrypted value structurepackage.json- Version bump to 0.0.12Test Plan
The existing test at
test/commands/set-default.test.ts:100-105validates encrypted value creation. With the added mock handler validation, this test would fail before the fix and passes after.🤖 Generated with Claude Code