-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved configuration validation #278
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the improvements! Just a couple fixes.
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestBotConfig_IsValid(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't a success case. So a function that always fails will pass. (Which is the current case)
} | ||
|
||
// Validate access levels are within bounds | ||
if c.ChannelAccessLevel < ChannelAccessLevelAll || c.ChannelAccessLevel > ChannelAccessLevelNone { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is backwards. UserAccessLevelAll = 0
and ChannelAccessLevelNone = 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand your comment.
ChannelAccessLevelAll = 0
and ChannelAccessLevelNone = 3
. The code checks that the value passed to it is not less than 0 and not greater than 3. Is that not correct?
if c.ChannelAccessLevel < ChannelAccessLevelAll || c.ChannelAccessLevel > ChannelAccessLevelNone { | ||
return false | ||
} | ||
if c.UserAccessLevel < UserAccessLevelAll || c.UserAccessLevel > UserAccessLevelNone { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UserAccessLevelAll = 0
and UserAccessLevelNone = 3
. The code checks that the value passed to it is not less than 0 and not greater than 3. Is that not correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I read those wrong. Don't do code reviews while jet-legged kids 🛫
@@ -49,10 +57,30 @@ type BotConfig struct { | |||
} | |||
|
|||
func (c *BotConfig) IsValid() bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be nice to have this return an error with a specific failure. (I bet Aider could make this change pretty quick)
server/ai/configuration.go
Outdated
// Service-specific validation | ||
switch c.Service.Type { | ||
case ServiceTypeOpenAI: | ||
return c.Service.APIKey != "" && c.Service.OrgID != "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OrgID is optional.
Description