Repository navigation
fix(integrations): keep a connector's routing state off the pod read - #1731
Merged
Merged
Conversation
GET /api/integrations/:podId answers every member of the pod, and returned each row whole: chatId, linkedUserId, relayMap and messageBuffer are the bridge's routing state — where a reply lands, and the identity inbound messages are authored as — not the pod's content. A member of a shared pod could read another member's connector to that depth. withoutRoutingState / withRoutingState in integrationPublicConfig project the row for the viewer. The connector's creator and an instance administrator see it whole; every other member gets `linked` (derived from chatId, so no surface branches on an id it is no longer given) and keeps chatTitle. ChatRoom's four chatId reads move to `linked`, including for the creator, who needs the flag on both paths. relayMap, messageBuffer and webhookListenerEnabled join SERVER_OWNED_CONFIG_KEYS: the bridges write all three, and a client body that sets one names a destination or starts a listener the caller was never granted. Tests: integrations.routingState.test.js, real Integration/Pod/User rows on memory Mongo so both the toJSON credential strip and the projection run — member read redacted, creator and admin reads whole, an unlinked connector reported as linked: false, and a write body carrying the three server-owned keys persisted without them.
The pod read redacted a connector's routing state; PATCH /:id and the connect-code re-mint echoed the row whole to anyone canDeleteIntegration admits, which includes the pod's creator — who may not have created the connector. Both now go through the same viewer projection as the pod read, resolved by one shared helper so the two gates cannot drift apart.
Wren 69319: the projection belongs with the Integration JSON contract, so a
fourth echo cannot appear without noticing. projectIntegrationForViewer(row,
{ requesterId, isAdmin }) lives in integrationPublicConfig.ts; the route keeps
only the admin/creator lookup and the three call sites.
samxu01
pushed a commit
that referenced
this pull request
Sep 18, 2026
A change whose acceptance is visual has no tier today: jsdom has no layout engine, so a card that still shows the field it should redact and a flex bug that clips a row both pass every render test. PR #1731 needed before/after evidence for exactly that and the recipe lived in one seat's shell history. The runbook records the path that cost real time to rederive, all of it measured on this machine rather than read off the code: - the backend's CORS allow-list IS FRONTEND_URL, so every frontend port you serve must be in it or the app looks broken (CORS + net::ERR_FAILED rather than a layout bug); - REACT_APP_API_URL is baked in via an explicit vite `define` — no env var at runtime will move it — and it must be set because the localhost fallback is :5000, which AirPlay owns on some machines; - the repo `.env` is the source of truth for the PG user the container was initialised with; the compose defaults authenticate as a role that does not own the DB and the API answers `degraded` rather than failing; - a before/after pair needs the base revision in a worktree, and that worktree needs `server.fs.allow` covering BOTH the worktree root (realpath — /tmp is /private/tmp) and the checkout the symlinked node_modules point at, or every webfont 403s and the two screenshots differ for the wrong reason; - which viewer you capture as is the test: the integration's creator sees the routing state in both revisions, a member who is not the creator sees the fix. scripts/ui-evidence-shot.mjs writes a full-page PNG and a body.innerText dump, and prints non-2xx responses and console errors. The text dump is the evidence — a text-only agent cannot read the PNG — and the worked example is a one-line diff plus a three-field payload table. Docs plus one script; no product code.
lilyshen0722
added a commit
that referenced
this pull request
Sep 18, 2026
…es (#1739) * docs(runbooks): local UI render harness, and the script it uses A change whose acceptance is visual has no tier today: jsdom has no layout engine, so a card that still shows the field it should redact and a flex bug that clips a row both pass every render test. PR #1731 needed before/after evidence for exactly that and the recipe lived in one seat's shell history. The runbook records the path that cost real time to rederive, all of it measured on this machine rather than read off the code: - the backend's CORS allow-list IS FRONTEND_URL, so every frontend port you serve must be in it or the app looks broken (CORS + net::ERR_FAILED rather than a layout bug); - REACT_APP_API_URL is baked in via an explicit vite `define` — no env var at runtime will move it — and it must be set because the localhost fallback is :5000, which AirPlay owns on some machines; - the repo `.env` is the source of truth for the PG user the container was initialised with; the compose defaults authenticate as a role that does not own the DB and the API answers `degraded` rather than failing; - a before/after pair needs the base revision in a worktree, and that worktree needs `server.fs.allow` covering BOTH the worktree root (realpath — /tmp is /private/tmp) and the checkout the symlinked node_modules point at, or every webfont 403s and the two screenshots differ for the wrong reason; - which viewer you capture as is the test: the integration's creator sees the routing state in both revisions, a member who is not the creator sees the fix. scripts/ui-evidence-shot.mjs writes a full-page PNG and a body.innerText dump, and prints non-2xx responses and console errors. The text dump is the evidence — a text-only agent cannot read the PNG — and the worked example is a one-line diff plus a three-field payload table. Docs plus one script; no product code. * docs(runbooks): the local .env is untracked — make one before sourcing it Vera, on #1739: `.env` is not tracked, only `.env.example` is. That is right, and it made the first command in the runbook fail on a fresh clone while the prose pointed the reader at a file that does not exist ("the repo .env", "already in .env"). - new step 0: `[ -f .env ] || cp .env.example .env`, plus the grep that shows the values it needs to carry. `-f` rather than a bare `cp` because this machine already had a `.env` and a plain copy would have clobbered a developer's local secrets; - `.env.example` is named as the file those values actually live in; - `LOCAL_DEV_LOGIN_ENABLED=1` corrected to `=true` (the value in `.env.example`), with the reader cited (`localDevLoginService.ts:44`); - the base-worktree block says out loud that it sources the same local `.env`, since the worktree does not contain one; - gotchas row and See-also updated. Verified by running it, not by reading: copy `.env.example` to a temp `.env`, source it, `PG_USER=commonly PG_PASSWORD=password PG_DATABASE=commonly LOCAL_DEV_LOGIN_ENABLED=true [email protected] FRONTEND_URL=http://localhost:3000`. All seven bash blocks pass `bash -n`. Also tightened the Node bullet to what was actually measured (the 34/369 unit suites that die under the v26 on PATH) and noted that the capture script is not one of them — it resolves playwright from the root node_modules and launches chromium under v26.
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
GET /api/integrations/:podIdanswers every member of the pod, and returned each row whole.chatId,linkedUserId,relayMapandmessageBufferare a connector's routing state — where a reply lands, and the identity inbound messages are authored as — not the pod's content, so a member of a shared pod could read another member's connector to that depth.Viewer projection.
withoutRoutingState/withRoutingStateinbackend/models/integrationPublicConfig.ts. The connector's creator and an instance administrator get the row whole; every other member getslinked(derived fromchatId) and keepschatTitle. Applied in the route (backend/routes/integrations.ts), not inline at a call site, and to thetoJSON()output so the existing credential strip still runs.linkedis written on both paths — the owner's own view reads it too, or a connected connector would render as unconnected for its owner (one reader, one field).Server-owned keys.
relayMap,messageBufferandwebhookListenerEnabledjoinSERVER_OWNED_CONFIG_KEYS. The bridges write all three; a client body that sets one names a destination or starts a listener the caller was never granted.Frontend.
ChatRoom.tsx's fourconfig.chatIdreads move toconfig.linked— it was the onlychatIdreader insrc, and no frontend test asserts it or those status strings. Frontend suite run at this head, before Vera's read: 108/108 suites, 877/877 tests (cd frontend && npm test -- --watchAll=false;npm ciinstalled clean in this clone). Three paths feedtelegramIntegrationand all three read correctly: the projected pod list (getslinked),existingIntegration(from that same list), and the POST-create response, which carries none — correct, since a connector is unbound until the chat binds.Proof
backend/__tests__/unit/routes/integrations.routingState.test.js— 5/5 on realIntegration/Pod/Userrows over memory Mongo, so the realtoJSONtransform and the projection both run: member read redacted (withaccessTokenstill stripped), creator read whole, admin read whole, an unbound connector reported aslinked: falserather than absent, and a write body carrying the three keys persisted without them.npm run lint:ts: 0 errors.No leak-matrix rows are added (Wren 69288):
KNOWN_EXPOSURESis empty on main so there was no row to shrink, and seeding routing sentinels would add 8ALLOWED_DISCLOSURESrows for readers that are exempt by design — surface without a check. The dedicated suite above is the guard instead.Scope
Ported from the recovered pre-switch work at Wren's spec (69283). The rest of that stash was superseded by main and is not here: credential strip, pod access (
canViewPod/isPodMember), pod-keyedgates,relayMap.podId, bridgechatType,mintConnectCode,stripServerOwnedConfig.Review fix: the write routes echo the row too (
e0d7a393)Vera (69314/69315): the pod read was right, but the redaction had a second read path.
PATCH /api/integrations/:idis authorised bycanDeleteIntegration, which also admits the pod's creator — who may not have created the connector. It returnedres.json(updated)whole, so a no-op PATCH ({ isActive: true }) handed that memberchatId,linkedUserId,relayMapandmessageBufferback.Fixed in this commit, plus the same defect one route over:
PATCH /:idandPOST /:id/connect-codenow returnprojectConnectorForViewer(row, viewer), the same projection as the pod read. The connect-code echo shares both the gate and the shape (canDeleteIntegration); it is narrower — it 409s once a chat is bound — butlinkedUserIdis written when live relay flips on, which can precede the bind. The minted code still comes back to the member who minted it: the code is what they came for and it is not routing state.resolveConnectorViewer(admin/creator resolution) andprojectConnectorForViewer(the projection) are shared by all three responses, so the read and write gates cannot drift into disagreeing about who sees routing state.Tests (
integrations.routingState.test.js, now 8/8): a pod creator who is not the connector's creator PATCHes another member's pod-scoped row →linked: true,chatTitlekept, nochatId/linkedUserId/relayMap/messageBuffer,accessTokenstill stripped; the connector's creator gets the row whole from the same PATCH; the connect-code re-mint by that pod creator returns the code withlinkedUserIdgone andlinked: false.Mutation check: restoring the unprojected
res.json(updated)on PATCH fails 2 of the 8.Placement (Wren 69319): the projection lives with the rest of the Integration JSON contract —
projectIntegrationForViewer(row, { requesterId, isAdmin })inbackend/models/integrationPublicConfig.ts. The route keeps only the admin/creator lookup (resolveConnectorViewer) and the three call sites, so a fourth echo cannot appear without meeting the same helper.Frontend is untouched by these commits —
frontend/src/components/ChatRoom.tsxis still blob1de62ca5, so the owner pair posted againstc0ce84festill binds to the shipped file, and the 877/877 frontend result carries.UI evidence: the pair that shows the change (Wren 69321)
The owner pair proves inertness; the redacted view is the only place this PR changes pixels, so it gets a second pair. Viewer = the pod's creator, who is not the connector's creator; connector bound with no
chatTitle, so the swapped text is what renders.origin/main)fa6d9537)Chat -1001234567890Telegram chat connectedConnected to chat -1001234567890.Connected to this chat.Both shots at 1440×900; image blobs
6121784587…(before) and8e43b91f32…(after, a distinct file). Source blobs:ChatRoom.tsx65bc2359→1de62ca5;routes/integrations.ts43ef4477→eeb3cfda. The backend differs between these two shots as well as the component — main returnschatIdto that member and the branch returnslinked— which is the change itself, not a held-constant.Verification at
fa6d9537: routingState 8/8 (incl. the PATCH-echo and connect-code-echo guard); modelintegrationPublicConfig10/10 (4 new viewer-projection cases); integrations route + model + security tier 18 suites / 215 tests;two-way-integration-e2e23/23 (Node 20);npm run lint:ts0 errors.