-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: add API key ID to interceptions #20513
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
Conversation
|
|
Thank you @dannykopping for pointing out that changes in aibridge repo are not necessary. |
coderd/database/migrations/000396_add_aibridge_interceptions_api_key_id.up.sql
Show resolved
Hide resolved
| require.Equal(t, "openai", intc0.Provider) | ||
| require.Equal(t, "gpt-4.1", intc0.Model) | ||
| require.True(t, intc0.EndedAt.Valid) | ||
| require.WithinDuration(t, dbtime.Now(), intc0.EndedAt.Time, 10*time.Second) |
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.
Why dbtime.Now() vs intc0.StartedAt?
Why 10s? Can we not just validated that ended at > started at?
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 if there is a good way to verify time here. 10s is just a arbitrary number so it is close enough to believe that time is set correctly to Now() but also flake safe.
If we want to check time here I probably should check StartedAt using the same condition.
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.
What are you actually testing here, though? Just that the values were stored correctly?
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.
Yeah, testing if values are correctly stored / passed between all http/rpc/db layers.
Also I think this is the only place that tests translator (enterprise/x/aibridged/translator.go). All tests passed when I forgot to update translator until I've added check here which scared me a bit.
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.
OK, in that case I don't see why you need to test the time in this way; all you need to validate is that start/end time are set and that end > start, no?
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.
Changed to StartedAt < EndedAt && EndedAt - StartedAt < 5s
Just checking Started < Ended would not catch edge case where StartedAt would be set to zero value.
badad42 to
cb7afb0
Compare
| require.Equal(t, "openai", intc0.Provider) | ||
| require.Equal(t, "gpt-4.1", intc0.Model) | ||
| require.True(t, intc0.EndedAt.Valid) | ||
| require.WithinDuration(t, dbtime.Now(), intc0.EndedAt.Time, 10*time.Second) |
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.
OK, in that case I don't see why you need to test the time in this way; all you need to validate is that start/end time are set and that end > start, no?
5f1b9c4 to
78210b9
Compare
dannykopping
left a comment
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.
LGTM
3e33a1c to
0d59950
Compare
0d59950 to
d6e752e
Compare
Adds APIKeyID to interceptions.
Needed for tracking API key usage with bridge.
fixes #20001