Skip to content

Conversation

@pawbana
Copy link
Contributor

@pawbana pawbana commented Oct 28, 2025

Adds APIKeyID to interceptions.
Needed for tracking API key usage with bridge.
fixes #20001

@pawbana
Copy link
Contributor Author

pawbana commented Oct 28, 2025

For build / presubmits to pass aibrdge library version needs to be bumped so it includes: coder/aibridge#46
No longer needed.

@pawbana
Copy link
Contributor Author

pawbana commented Oct 28, 2025

For build / presubmits to pass aibrdge library version needs to be bumped so it includes: coder/aibridge#46

Thank you @dannykopping for pointing out that changes in aibridge repo are not necessary.

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@pawbana pawbana force-pushed the pb/aibridge-intc-api-key branch 2 times, most recently from badad42 to cb7afb0 Compare October 29, 2025 14:46
@pawbana pawbana requested a review from dannykopping October 29, 2025 16:37
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)
Copy link
Contributor

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?

@pawbana pawbana force-pushed the pb/aibridge-intc-api-key branch from 5f1b9c4 to 78210b9 Compare October 30, 2025 14:42
@github-actions github-actions bot added the stale This issue is like stale bread. label Nov 7, 2025
@pawbana pawbana requested a review from dannykopping November 10, 2025 11:14
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pawbana pawbana force-pushed the pb/aibridge-intc-api-key branch from 3e33a1c to 0d59950 Compare November 10, 2025 11:59
@pawbana pawbana force-pushed the pb/aibridge-intc-api-key branch from 0d59950 to d6e752e Compare November 10, 2025 12:11
@pawbana pawbana merged commit 991831b into main Nov 10, 2025
47 of 51 checks passed
@pawbana pawbana deleted the pb/aibridge-intc-api-key branch November 10, 2025 12:46
@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

stale This issue is like stale bread.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enhancement: track API key used to authenticate for aibridge requests

3 participants