fix(settings): resolve bugs with completions/validation#208
fix(settings): resolve bugs with completions/validation#208water-sucks merged 5 commits intonix-community:mainfrom
Conversation
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughEnhanced password method handling in settings framework by updating reflection API usage, refactoring flag parsing logic, adding password method completion support, and implementing custom unmarshaling for PasswordInputMethod type validation. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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.11.4)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/settings/settings.go (1)
567-575: Preserve field context whenUnmarshalTextfails.Returning raw unmarshaler errors here makes diagnostics less consistent than the typed parse branches. Consider wrapping with the config key/field path.
Proposed diff
if current.CanAddr() { if unmarshaler, ok := current.Addr().Interface().(encoding.TextUnmarshaler); ok { if err := unmarshaler.UnmarshalText([]byte(value)); err != nil { - return err + return SettingsError{ + Field: key, + Message: err.Error(), + } } return nil } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/settings/settings.go` around lines 567 - 575, Wrap errors returned from unmarshaler.UnmarshalText with a contextual message that includes the config key/field path so diagnostics match other parse branches: inside the block where current.CanAddr() and current.Addr().Interface().(encoding.TextUnmarshaler) are used, change the error return to wrap the unmarshaler error (e.g. return fmt.Errorf("unmarshal text for %s: %w", <keyOrFieldPath>, err)) and add fmt to imports if necessary; use the same identifier used elsewhere for the config key/field path (e.g. key, path, or fieldPath) to keep messages consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@internal/settings/settings.go`:
- Around line 567-575: Wrap errors returned from unmarshaler.UnmarshalText with
a contextual message that includes the config key/field path so diagnostics
match other parse branches: inside the block where current.CanAddr() and
current.Addr().Interface().(encoding.TextUnmarshaler) are used, change the error
return to wrap the unmarshaler error (e.g. return fmt.Errorf("unmarshal text for
%s: %w", <keyOrFieldPath>, err)) and add fmt to imports if necessary; use the
same identifier used elsewhere for the config key/field path (e.g. key, path, or
fieldPath) to keep messages consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0add7534-165a-4eb6-8a7a-26198b235ec1
📒 Files selected for processing (2)
internal/settings/completion.gointernal/settings/settings.go
Some bugs existed with the settings, including:
--confignot validating passed string enum valuesThis PR finds those and resolves them, and also uses
UnmarshalText()when needed to ensure strong validation of enum keys.Summary by CodeRabbit