Skip to content

General: Adopt the shared authenticated axios instance in phase components - #2068

Merged
rappm merged 5 commits into
mainfrom
feature/shared-axios-instance
Aug 22, 2026
Merged

General: Adopt the shared authenticated axios instance in phase components#2068
rappm merged 5 commits into
mainfrom
feature/shared-axios-instance

Conversation

@rappm

@rappm rappm commented Aug 20, 2026

Copy link
Copy Markdown
Member

Summary

Removes the duplicated authenticated axios setup from the phase components and replaces it with the
createAuthenticatedAxiosInstance factory that @tumaet/prompt-shared-state 1.2.0 exports.

Details

  • Bumped @tumaet/prompt-shared-state and @tumaet/prompt-ui-components to 1.2.0 in
    clients/package.json and regenerated clients/yarn.lock.
  • Replaced the local axios.create plus request interceptor in six phase configs with
    createAuthenticatedAxiosInstance(env.<PHASE>_HOST): assessment, certificate, example, interview,
    self team allocation, team allocation.
  • Deleted the five dead local copies of the Patch interface (assessment, example, interview, self
    team allocation, team allocation). Nothing imported them, so no import rewiring was needed; the
    interface is now exported by @tumaet/prompt-shared-state for future consumers.
  • Deleted clients/self_team_allocation_component/.../network/coreServerConfig.ts and pointed its
    single consumer at the shared axiosInstance singleton instead of the factory. That singleton is
    already bound to env.CORE_HOST, and the team allocation component calls the very same core
    endpoint through it, so reusing it removes a whole file rather than replacing one duplicate with
    another. It also brings the sanitized response error logging that the singleton carries.

Interceptor equivalence was verified against the shipped 1.2.0 build before deleting the local code:

  • The local guard localStorage.getItem('jwt_token') && ... !== '' and the factory's if (token)
    behave identically, since the empty string is falsy. The factory adds a
    typeof localStorage !== 'undefined' guard, which is strictly safer.
  • config.headers.Authorization and config.headers['Authorization'] are the same assignment.
  • The local configs resolved parseURL(host) once at module load; the factory resolves it per
    request inside the interceptor. Same value either way, because env is a snapshot normalized at
    module load.

No behavioral regressions found. The only behavior change is the additive response error logging on
the one self team allocation core query, which comes from switching to the shared singleton.

Out of scope: the inlined try { } catch (err) { console.error(err); throw err } wrappers in the
network layers stay untouched. createAuthenticatedAxiosInstance installs only the request
interceptor and logNetworkError is not publicly exported, so removing them would silently drop all
network error logging in the phase components. That cleanup is #1985 and remains blocked.

The dependency bump in the first commit is intentionally identical to the one on the branches for
#1987 and #1988, so those PRs are unblocked by the same version and the three branches merge cleanly
instead of conflicting on clients/package.json and clients/yarn.lock.

Reason / Link to issue

Closes #1979

How to Test

  1. cd clients && yarn install --immutable
  2. make lint
  3. cd clients/<component> && npx tsc --noEmit -p tsconfig.json && yarn build for each of the six
    touched components.
  4. Run the stack and open an assessment, interview, certificate, team allocation, and self team
    allocation phase. Requests must still carry the Authorization: Bearer header and hit the
    correct per-phase host.

PR Checklist

  • Tested locally or on the dev environment
  • Code is clean, readable, and documented
  • Tests added or updated (if needed)
  • Screenshots attached for UI changes (if any)
  • Documentation updated (if relevant)

rappm added 3 commits August 20, 2026 20:03
prompt-shared-state 1.2.0 exports createAuthenticatedAxiosInstance and the
shared Patch interface, which the phase components need in order to drop their
local axios configs.
Replace the six per-phase axios configs with createAuthenticatedAxiosInstance
from @tumaet/prompt-shared-state and drop the five dead local copies of the
Patch interface, which is now exported by the shared package.

The inlined try/catch logging in the network layers stays untouched: the shared
factory only installs the request interceptor, so removing those would drop the
error logging entirely.
The local coreServerConfig duplicated the axiosInstance singleton that
@tumaet/prompt-shared-state already binds to env.CORE_HOST. The team allocation
component already calls the same core endpoint through that singleton, so the
local config is removed in favor of it.
@rappm
rappm requested a review from a team August 20, 2026 18:06
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@rappm, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 17 minutes

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7f2294f9-68da-43ec-b209-e17b4f484c40

📥 Commits

Reviewing files that changed from the base of the PR and between 2538ea3 and 4bed9c0.

⛔ Files ignored due to path filters (1)
  • clients/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (11)
  • clients/assessment_component/src/assessment/network/assessmentServerConfig.ts
  • clients/assessment_component/src/assessment/pages/AssessmentPage/components/AssessmentCompletion/hooks/useDeleteAssessmentCompletion.tsx
  • clients/assessment_component/src/assessment/pages/AssessmentPage/components/CategoryComment/hooks/useCreateOrUpdateCategoryAssessment.tsx
  • clients/certificate_component/src/certificate/network/certificateServerConfig.ts
  • clients/example_component/src/example_component/network/exampleServerConfig.ts
  • clients/interview_component/src/interview/network/interviewServerConfig.ts
  • clients/package.json
  • clients/self_team_allocation_component/src/self_team_allocation/network/coreServerConfig.ts
  • clients/self_team_allocation_component/src/self_team_allocation/network/queries/getStudentsOfCoursePhase.ts
  • clients/self_team_allocation_component/src/self_team_allocation/network/selfTeamAllocationServerConfig.ts
  • clients/team_allocation_component/src/team_allocation/network/teamAllocationServerConfig.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

mathildeshagl
mathildeshagl previously approved these changes Aug 22, 2026

@mathildeshagl mathildeshagl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving. Good refactor, and the interceptor-equivalence section in the description is the reason this was quick to review.

I checked the claims against the published @tumaet/prompt-shared-state@1.2.0 tarball rather than taking them on trust, and they all hold:

  • The factory does parseURL(baseHost || '') internally, so passing env.X_HOST straight in needs no local || ''.
  • if (token) is equivalent to the old getItem() && getItem() !== '', and the typeof localStorage !== 'undefined' guard is strictly safer.
  • env really is a module-load snapshot (normalizeEnv(window.env) evaluated at import), so resolving parseURL per request instead of once at module load gives the same value. That was the claim most worth checking and it is correct.

The refactor is also complete rather than partial: all seven duplicated setups under clients/ are accounted for, six replaced and one deleted. And Patch is declared in five files and imported by none, so deleting it needed no import rewiring, as you say.

One equivalence the description doesn't cover, worth knowing rather than changing: baseURL moves from an instance default to a request interceptor, so a per-request baseURL override would now be overwritten instead of taking precedence. No call site does that today (the only baseURL occurrences in clients/ are the ones this PR deletes), so it is latent rather than a bug. Absolute URLs passed as url are unaffected either way, since axios ignores baseURL for those.

Cosmetic, take it or leave it: const x = createAuthenticatedAxiosInstance(...) followed by export { x } could be a single export const. It does preserve the shape the files already had, which is a fair reason to keep it.

Agreed on leaving the try/catch wrappers alone until #1985 unblocks.

…instance

# Conflicts:
#	clients/package.json
#	clients/yarn.lock
@rappm
rappm merged commit 0ad171f into main Aug 22, 2026
88 of 89 checks passed
@rappm
rappm deleted the feature/shared-axios-instance branch August 22, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

schau mi o Translation: Ready to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt the shared authenticated axios instance in phase components

2 participants