Harden architecture hot paths
This commit is contained in:
@@ -2970,7 +2970,7 @@ describe("Attachment routes", () => {
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.body).toEqual(fakeLogs);
|
||||
expect(store.getAgentLogs).toHaveBeenCalledWith("KB-001");
|
||||
expect(store.getAgentLogs).toHaveBeenCalledWith("KB-001", undefined);
|
||||
});
|
||||
|
||||
it("GET /tasks/:id/logs — returns empty array when no logs", async () => {
|
||||
|
||||
@@ -2829,7 +2829,12 @@ export function createApiRoutes(store: TaskStore, options?: ServerOptions): Rout
|
||||
router.get("/tasks/:id/logs", async (req, res) => {
|
||||
try {
|
||||
const scopedStore = await getScopedStore(req);
|
||||
const logs = await scopedStore.getAgentLogs(req.params.id);
|
||||
const limit = typeof req.query.limit === "string"
|
||||
? Number.parseInt(req.query.limit, 10)
|
||||
: undefined;
|
||||
const logs = await scopedStore.getAgentLogs(req.params.id, limit !== undefined && Number.isFinite(limit)
|
||||
? { limit }
|
||||
: undefined);
|
||||
res.json(logs);
|
||||
} catch (err: any) {
|
||||
if (err instanceof ApiError) {
|
||||
|
||||
Reference in New Issue
Block a user