Repository navigation
UN-4313 [FEAT] Add the v1 data layer: one HTTP client, server state and error contract - #2482
Draft
kirtimanmishrazipstack wants to merge 2 commits into
Draft
kirtimanmishrazipstack wants to merge 2 commits into
kirtimanmishrazipstack wants to merge 2 commits into
Conversation
…nd error contract - services/http.ts: one axios client; CSRF on same-origin mutating requests, a request id on every request, ApiError rejections, one redirect for concurrent 401s. - services/context.ts: the org id and session-expiry hook UN-4314 sets. - services/errors.ts and report.ts: one error shape, form field mapping, one reporter; app/query.ts wires it into the v1 QueryClient. - QueryView pattern, page contract, sample adapters service on the demo page. - lint:v1 rejects backend URLs, axios and the client outside services/. Co-Authored-By: Claude Opus 5.5 <[email protected]>
kirtimanmishrazipstack
left a comment
Contributor
Author
There was a problem hiding this comment.
Standardized review (unstract v2.1.80): REQUEST CHANGES
Summary: Critical: 0 · High: 2 · Medium: 7 · Low: 8 · Lenses run: 19/19 (15 examined, 4 N/A)
- Security deep-dive: done, no findings at confidence >= 8.
- Boundary sweep: 7 sinks traced, clean.
test:v1passes on Node 26 (720 tests, 182/182 guardrail fixtures).lint:v1,typecheck:v1and Biome 2.3.13 are clean on the changed files.
Lens checklist
- Spec & intent: See findings #4
- Architectural fit: See findings #7, #15, #17
- Correctness: See findings #1, #6, #10
- Security: Clean
- Data integrity: N/A (frontend only)
- Concurrency: See findings #5, #7
- API & contract: See findings #3, #11
- Reliability: See findings #6
- Performance: Clean
- Observability: Clean
- Operational safety: Clean (v1 only, behind the version switch)
- LLM/agent: N/A
- Testing: See findings #2, #8, #16
- Dependencies: Clean (no manifest change)
- Code quality: See findings #15
- Doc accuracy: See findings #1, #5, #12, #13, #14
- Cross-document: See findings #9
- On-prem: N/A
- Scaling: N/A
Open questions
- #5: must UN-4314's expiry handler leave the page, or should the latch re-arm?
- #3: for typed 401s, a client-side check or a backend remap of
SdkError401? - v0 sends
subscription_errorto/subscription-expired, but v1 shows a toast. Is that intended? - The defaults keep
staleTime: 0with refetch on focus, so every mounted query refetches on each tab focus. Is that the default you want? - A page past the end returns 404 "Invalid page.". Should paged queries step back a page?
Unanchored findings
frontend/src/v1/test/README.md:153(outside the diff hunk): 9. [Medium] [Lens 17] — This fixture example contradicts the realtest/fixtures/adapters.ts
The real file this PR adds has adapterFixtures.llm and adapterHandlers(session, rows, seen), and the new Adapter type needs more fields than this example has (satisfies would fail). L110 uses adapterFixtures.list, which doesn't exist. Suggest deleting the block, pointing to the real file, and fixing L110. Made stale by test/fixtures/adapters.ts:L6.
frontend/src/v1/README.md:143(outside the diff hunk): 13. [Low] [Lens 16] — A 401 from a service call now redirects to sign in, so "no … login redirect" is out of date.
…e, org-scoped queries, stricter lint - A typed 401 (a provider's key, a connector's OAuth) is a client error; only the auth middleware's 401 expires the session. - toApiError calls a cancel unknown, not network; mapFieldErrors gives nothing for no error or a cancel. - QueryView shows the alert only when the first fetch failed; a failed refresh keeps the data. - networkMode always: offline fails as network instead of pausing, and a save is never sent later. - Queries fetch for the org in their key; orgPath moves into http.ts with an org option. - lint:v1 matches the client under any spelling and flags fetch, XMLHttpRequest and EventSource outside services/; plugins/<plugin>/services/ may hold them. - Drop the unused query-level meta.notify; document the once-per-page-load expiry and fix the README rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Contributor
Author
|
Answers to the findings and questions in the review body. The fixes are in 74db2e1.
Open questions:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
Why
How
services/http.tsis the only HTTP client, and builds the org-scoped paths (orgPath()). It:X-CSRFTokento same-origin POST, PUT, PATCH and DELETE requests;X-Request-IDto every request;ApiError;clienterror.mapFieldErrors()turns errors for fields the form doesn't show into one form-level error, and gives nothing before the first submit.app/query.ts):networkMode: "always", so offline fails at once instead of pausing, and a save is never sent later;QueryViewwhen the first fetch fails, otherwise as a toast;lint:v1rejects backend URLs, axios, the client andfetch/XMLHttpRequest/EventSourceoutsideservices/(and a cloud plugin'splugins/<plugin>/services/).services/README.md.NODE_OPTIONS=--no-experimental-webstorage. CI uses Node 22 and needs nothing extra.Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
Screenshots
Checklist
I have read and understood the Contribution Guidelines.
🤖 Generated with Claude Code