fix(server): a deregistered T3 Connect host shows it was removed and offers a relink #19379
Mergedt3dotgg(GitHub profile, opens in a new tab)merged 4 commits into
main fromrefs/pull/19379/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
t3dotgg(GitHub profile, opens in a new tab) changed the title
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/cloud/CloudLink.ts line 1089OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1069,4 +1073,17 @@10691073 proof,10701074 },10711075 schema: RelayManagedEndpointRecoveryRegistrationResponse,1072- });1076+ }).pipe(1077+ // A 401 here means the relay no longer accepts this link, usually because1078+ // the environment was deregistered. Retrying cannot fix that, and relinking1079+ // is the user's call, so only mark it. Nothing stored is removed: the relay1080+ // also answers 401 for a skewed clock, and the next accepted registration1081+ // clears the mark.1082+ Effect.catchTags({1083+ RelayRequestError: (error) =>1084+ error.rejection === "unauthorized"1085+ ? Effect.logWarning(1086+ "T3 Connect no longer accepts this environment's link. Link it again to restore remote access.",1087+ { cause: error },1088+ ).pipe(1089+ Effect.andThen(secrets.set(CLOUD_LINK_REVOKED, stringToBytes("true"))),
- apps/server/src/cloud/CloudLink.ts lines 1102 to 1104Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1069,4 +1073,12 @@10691073 proof,10701074 },10711075 schema: RelayManagedEndpointRecoveryRegistrationResponse,1072- });1076+ }).pipe(1077+ // A 401 here means the relay no longer accepts this link, usually because1078+ // the environment was deregistered. Retrying cannot fix that, and relinking1079+ // is the user's call, so only mark it. Nothing stored is removed: the relay1080+ // also answers 401 for a skewed clock, and the next accepted registration1081+ // clears the mark.1082+ Effect.catchTags({1083+ RelayRequestError: (error) =>1084+ error.rejection === "unauthorized"apps/server/src/cloud/CloudLink.ts line 1089OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1069,4 +1073,17 @@10691073 proof,10701074 },10711075 schema: RelayManagedEndpointRecoveryRegistrationResponse,1072- });1076+ }).pipe(1077+ // A 401 here means the relay no longer accepts this link, usually because1078+ // the environment was deregistered. Retrying cannot fix that, and relinking1079+ // is the user's call, so only mark it. Nothing stored is removed: the relay1080+ // also answers 401 for a skewed clock, and the next accepted registration1081+ // clears the mark.1082+ Effect.catchTags({1083+ RelayRequestError: (error) =>1084+ error.rejection === "unauthorized"1085+ ? Effect.logWarning(1086+ "T3 Connect no longer accepts this environment's link. Link it again to restore remote access.",1087+ { cause: error },1088+ ).pipe(1089+ Effect.andThen(secrets.set(CLOUD_LINK_REVOKED, stringToBytes("true"))),apps/server/src/cloud/managedTunnelStartup.ts lines 6 to 9Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -3,5 +3,7 @@33 import * as Effect from "effect/Effect";44 import * as Schedule from "effect/Schedule";556+// "revoked" leads to no action: relinking a deregistered environment is the7+// user's call, so startup neither retries nor relinks it.68 export type ManagedTunnelRegistrationResult =7- | { readonly status: "not_linked" | "ready" | "unavailable" | "superseded" }9+ | { readonly status: "not_linked" | "ready" | "unavailable" | "superseded" | "revoked" }
- apps/server/src/cloud/CloudLink.ts lines 1193 to 1195Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1135,13 +1177,19 @@11351177 origin,11361178 });1179+ const credential = bytesToString(environmentCredential.value);11371180 const recovered = yield* relayClientRequest({11381181 url: `${relayUrlValue}/v1/environments/${encodeURIComponent(environmentId)}/tunnel`,1139- token: bytesToString(environmentCredential.value),1182+ token: credential,11401183 payload: {11411184 cloudUserId: cloudUserIdValue,11421185 origin,11431186 proof,11441187 },11451188 schema: RelayManagedEndpointRecoveryResponse,11461189 timeout: MANAGED_ENDPOINT_PROVISION_REQUEST_TIMEOUT,1147- });1190+ }).pipe(1191+ // A running host learns of a Deregister here, when its dead tunnel asks1192+ // for a replacement. The rejection still fails the recovery.1193+ Effect.tapError((error) =>1194+ error.rejection === "unauthorized" ? markLinkRevoked(credential, error) : Effect.void,1195+ ),
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This cross-layer change alters how rejected cloud credentials control tunnel startup and recovery, persists revoked-link state, and changes relinking and remote-access behavior across the server, CLI, and web clients. The access-control implications and significant runtime gate require human review.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).