Skip to content

Conversation

@dmivankov
Copy link
Contributor

@dmivankov dmivankov commented Nov 27, 2025

In addition to baseSttpBackend allow settign wrapSttpClient.
GenericClient inserts auth wrapper in between and before setting
retrying wrapper as base client would mean each retry is using same
auth headers, which could expire for long and numerous retries.

With new argument caller can move retrying wrapper from base client to
wrapping argument and get up-to-date auth on each attempt.

CDF-26312

In addition to baseSttpBackend allow settign wrapSttpClient.
GenericClient inserts auth wrapper in between and before setting
retrying wrapper as base client would mean each retry is using same
auth headers, which could expire for long and numerous retries.

With new argument caller can move retrying wrapper from base client to
wrapping argument and get up-to-date auth on each attempt.

[CDF-26312]
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a wrapSttpBackend argument to GenericClient, allowing for more flexible customization of the STTP backend, particularly for handling retries with token refreshes. The implementation is sound and correctly applies the wrapper around the authentication backend. I've found one minor issue where cdfVersion is not passed when creating the RequestSession for token inspection, which could lead to issues in multi-cluster environments. I've left a specific comment with a suggestion to fix it.

lazy val token =
new Token[F](RequestSession(applicationName, uri, sttpBackend, authProvider, clientTag))
new Token[F](
RequestSession(applicationName, uri, sttpBackend, wrapSttpBackend, authProvider, clientTag)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The RequestSession created for token is missing the cdfVersion parameter. This means that requests made by the token instance (e.g., token.inspect()) will not include the cdf-version header, which could lead to incorrect request routing in multi-cluster environments. Please add cdfVersion to the RequestSession constructor call to ensure consistent behavior with other API requests.

Suggested change
RequestSession(applicationName, uri, sttpBackend, wrapSttpBackend, authProvider, clientTag)
RequestSession(applicationName, uri, sttpBackend, wrapSttpBackend, authProvider, clientTag, cdfVersion)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will look into it separately

@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.73%. Comparing base (cd200d2) to head (b0828a2).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #904   +/-   ##
=======================================
  Coverage   84.73%   84.73%           
=======================================
  Files          99       99           
  Lines        2738     2738           
  Branches      211      184   -27     
=======================================
  Hits         2320     2320           
  Misses        418      418           
Files with missing lines Coverage Δ
...scala/com/cognite/sdk/scala/v1/GenericClient.scala 83.33% <100.00%> (ø)
...cala/com/cognite/sdk/scala/v1/RequestSession.scala 83.87% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

This pull request seems a bit stale.. Shall we invite more to the party?

@github-actions github-actions bot added the Stale label Nov 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants