Skip to content

Commit 2e6082f

Browse files
os-zhuangclaude
andcommitted
fix(runtime): resolve share-link record/messages via the per-env kernel
handleShareLinks fetched the record via resolveService('objectql', env), which can return a different (host/scoped) engine that lacks the per-env rows — so resolve/messages 410'd even though the record existed. Read objectql from this.kernel (the request's resolved per-env kernel), the same engine SharingServicePlugin bound the shareLinks service to. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 31e2f5a commit 2e6082f

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

packages/runtime/src/http-dispatcher.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2836,7 +2836,21 @@ export class HttpDispatcher {
28362836
});
28372837
// Engine for fetching the shared record + token probes — the same
28382838
// per-env ObjectQL the shareLinks service is bound to.
2839-
const getEngine = () => this.resolveService('objectql', context.environmentId);
2839+
const getEngine = async (): Promise<any> => {
2840+
// Read objectql from the request's RESOLVED (per-env) kernel — the
2841+
// same engine SharingServicePlugin bound the shareLinks service to,
2842+
// so the shared record + messages live in the SAME store as
2843+
// sys_share_link. `resolveService('objectql', env)` can hand back a
2844+
// different (host/scoped) engine that lacks the per-env rows.
2845+
try {
2846+
const k: any = this.kernel;
2847+
const e = typeof k?.getServiceAsync === 'function'
2848+
? await k.getServiceAsync('objectql')
2849+
: k?.getService?.('objectql');
2850+
if (e) return e;
2851+
} catch { /* fall through to scoped resolution */ }
2852+
return this.resolveService('objectql', context.environmentId);
2853+
};
28402854
const asArray = (rows: any): any[] => (Array.isArray(rows) ? rows : Array.isArray(rows?.value) ? rows.value : []);
28412855
const applyRedaction = (record: any, redactFields: string[]): any => {
28422856
if (!record || typeof record !== 'object' || redactFields.length === 0) return record;

0 commit comments

Comments
 (0)