chore: update baton-sdk to v0.7.16#7
Conversation
WalkthroughThese changes upgrade the baton-sdk dependency and introduce Discord bot configuration support. A new configuration schema is defined with a token field, with corresponding accessor methods auto-generated into a new file. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 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)
Comment |
05343c0 to
3fcff2c
Compare
3fcff2c to
9699a94
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@pkg/config/conf.gen.go`:
- Around line 10-23: The method findFieldByTag on type Discord currently calls
reflect.ValueOf(c).Elem() and will panic if the receiver *Discord is nil; add a
defensive nil check at the start of findFieldByTag (check if c == nil) and
return nil, false immediately when nil, so callers safely get no-value instead
of crashing; keep the rest of the logic (using reflect.ValueOf(c).Elem(),
t.NumField(), field.Tag.Get("mapstructure"), and v.Field(i).Interface())
unchanged.
🧹 Nitpick comments (1)
go.mod (1)
7-10: Move ruleguard dependencies to a tools.go file.These packages are only used in
tools/rules.go(which has//go:build ruleguardconstraints) and are not part of the production binary. Moving them to a dedicated tools.go file follows Go best practices and reduces the main module's dependency surface.♻️ Suggested approach
- github.com/ennyjfrick/ruleguard-logfatal v0.0.2 - github.com/quasilyte/go-ruleguard/dsl v0.3.23Add a tools-only file (example
tools.goat repo root)://go:build tools // +build tools package tools import ( _ "github.com/ennyjfrick/ruleguard-logfatal" _ "github.com/quasilyte/go-ruleguard/dsl" )
| func (c *Discord) findFieldByTag(tagValue string) (any, bool) { | ||
| v := reflect.ValueOf(c).Elem() // Dereference pointer to struct | ||
| t := v.Type() | ||
|
|
||
| for i := 0; i < t.NumField(); i++ { | ||
| field := t.Field(i) | ||
| tag := field.Tag.Get("mapstructure") | ||
|
|
||
| if tag == tagValue { | ||
| return v.Field(i).Interface(), true | ||
| } | ||
| } | ||
| return nil, false | ||
| } |
There was a problem hiding this comment.
Guard against nil receiver to avoid panics in config accessors.
If *Discord is nil, reflect.ValueOf(c).Elem() panics. A defensive nil check prevents accidental crashes.
✅ Suggested fix (update generator)
func (c *Discord) findFieldByTag(tagValue string) (any, bool) {
+ if c == nil {
+ return nil, false
+ }
v := reflect.ValueOf(c).Elem() // Dereference pointer to struct
t := v.Type()📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| func (c *Discord) findFieldByTag(tagValue string) (any, bool) { | |
| v := reflect.ValueOf(c).Elem() // Dereference pointer to struct | |
| t := v.Type() | |
| for i := 0; i < t.NumField(); i++ { | |
| field := t.Field(i) | |
| tag := field.Tag.Get("mapstructure") | |
| if tag == tagValue { | |
| return v.Field(i).Interface(), true | |
| } | |
| } | |
| return nil, false | |
| } | |
| func (c *Discord) findFieldByTag(tagValue string) (any, bool) { | |
| if c == nil { | |
| return nil, false | |
| } | |
| v := reflect.ValueOf(c).Elem() // Dereference pointer to struct | |
| t := v.Type() | |
| for i := 0; i < t.NumField(); i++ { | |
| field := t.Field(i) | |
| tag := field.Tag.Get("mapstructure") | |
| if tag == tagValue { | |
| return v.Field(i).Interface(), true | |
| } | |
| } | |
| return nil, false | |
| } |
🤖 Prompt for AI Agents
In `@pkg/config/conf.gen.go` around lines 10 - 23, The method findFieldByTag on
type Discord currently calls reflect.ValueOf(c).Elem() and will panic if the
receiver *Discord is nil; add a defensive nil check at the start of
findFieldByTag (check if c == nil) and return nil, false immediately when nil,
so callers safely get no-value instead of crashing; keep the rest of the logic
(using reflect.ValueOf(c).Elem(), t.NumField(), field.Tag.Get("mapstructure"),
and v.Field(i).Interface()) unchanged.
Summary
Status
go build ./...passes)