fix: set SecretTypePlainText for plain-text JSON and non-prefixed secret values - #4946
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughModifies ChangesSecret Type Defaulting
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
SecretTypePlainText for plain-text JSON and non-prefixed secret values
This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
core/schemas/secretvar.go (1)
85-87: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd table-driven tests for the new defaulting behavior.
None of the three new defaulting paths (plain-value JSON object, non-prefixed plain string, and the
UnmarshalJSONcatch-all) have accompanying test cases in the diff, even though they change observable JSON serialization output (typefield now populated instead of omitted). As per coding guidelines, Go core changes should include "table-driven coverage for behavior changes."Also applies to: 99-99, 360-362
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@core/schemas/secretvar.go` around lines 85 - 87, Add table-driven tests for the new defaulting behavior in secretvar.go. Cover the three observable paths introduced by SecretVar.UnmarshalJSON and related defaulting logic: plain-value JSON objects, non-prefixed plain string inputs, and the catch-all path that now sets SecretType instead of leaving it omitted. Use the SecretVar and UnmarshalJSON symbols to verify the serialized JSON now includes the expected type field for each case, matching the new defaulting behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@core/schemas/secretvar.go`:
- Around line 85-87: Add table-driven tests for the new defaulting behavior in
secretvar.go. Cover the three observable paths introduced by
SecretVar.UnmarshalJSON and related defaulting logic: plain-value JSON objects,
non-prefixed plain string inputs, and the catch-all path that now sets
SecretType instead of leaving it omitted. Use the SecretVar and UnmarshalJSON
symbols to verify the serialized JSON now includes the expected type field for
each case, matching the new defaulting behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 88c7b94c-8bf6-4d20-a4e7-50ef85219e4c
📒 Files selected for processing (1)
core/schemas/secretvar.go
Merge activity
|

Summary
Ensures that
SecretVarinstances parsed from plain-text values (i.e., JSON objects with avaluefield but notype,ref, orfrom_env) are explicitly tagged withSecretTypePlainTextrather than left with an emptySecretType. Previously, these cases fell through without a type assignment, making it ambiguous whether a secret was intentionally plain text or simply uninitialized.Changes
type,ref, orfrom_envfield,SecretTypeis now explicitly set toSecretTypePlainText.parseSecretRefreturns a plain string value (noenv.orvault.prefix), the returnedSecretVarnow carriesSecretTypePlainText.UnmarshalJSON, ifSecretTyperemains empty after processing a recognized JSON structure, it is defaulted toSecretTypePlainText.Type of change
Affected areas
How to test
go test ./core/schemas/...Verify that a
SecretVarparsed from a plain string or a JSON object like{"value": "my-secret"}hasSecretType == SecretTypePlainTextrather than an empty string.Breaking changes
Security considerations
This change makes secret type classification more explicit. Code that previously relied on an empty
SecretTypeto identify plain-text secrets should be reviewed to ensure it handlesSecretTypePlainTextcorrectly.Checklist
docs/contributing/README.mdand followed the guidelines