Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix([issue-3109]): validate the style-reference DELETE param and correct two stale comments
[._.]/ Adam Eivy95a1dd3fa2ae
diff --git a/client/src/hooks/useUniverseDraft.js b/client/src/hooks/useUniverseDraft.jsindex 481a99584f..a1d230fc92 100644--- a/client/src/hooks/useUniverseDraft.js+++ b/client/src/hooks/useUniverseDraft.js@@ -354,12 +354,11 @@ export default function useUniverseDraft({ selectedId, goToWorld }) {// now-selected universe's draft. Nothing is lost by dropping it: the change// is already persisted, and the server owns the array now.//- // `adopt` is true when the same request also wrote the style guide, in which- // case the guide fields are folded in too (and banked as saved) unless the- // user edited them while the request was in flight.// `capturedStyle` is the style guide as it read when an ADOPT request was- // issued; passing it is what marks the response as an adopt. A plain add or- // remove passes nothing, because it wrote no guidance to fold in.+ // issued; passing it is what marks the response as an adopt, so the guide+ // fields are folded in too (and banked as saved) — unless the user edited them+ // while the request was in flight. A plain add or remove passes nothing,+ // because it wrote no guidance to fold in.const applyStyleReferenceResult = useCallback((targetId, updated, capturedStyle = null) => {noteUniverseUpdated(targetId, updated.updatedAt);if (selectedIdRef.current === targetId) {diff --git a/server/routes/universeBuilder.js b/server/routes/universeBuilder.jsindex d137955c47..0a58cd97b1 100644--- a/server/routes/universeBuilder.js+++ b/server/routes/universeBuilder.js@@ -921,8 +921,15 @@ router.post('/:id/style-references', asyncHandler(async (req, res) => {res.json(w);}));+// The id is only ever compared against stored reference ids (never used as a+// path/SQL operand), but validate it anyway so an absurdly long param is a 400+// here rather than a silent no-op deeper in.+const removeStyleReferenceParamsSchema = z.object({+ referenceId: entryIdField.unwrap(),+});router.delete('/:id/style-references/:referenceId', asyncHandler(async (req, res) => {- const w = await svc.removeStyleReference(req.params.id, req.params.referenceId)+ const { referenceId } = validateRequest(removeStyleReferenceParamsSchema, req.params);+ const w = await svc.removeStyleReference(req.params.id, referenceId).catch((err) => { throw mapServiceError(err); });res.json(w);}));diff --git a/server/routes/universeBuilder.test.js b/server/routes/universeBuilder.test.jsindex 3ac5b81057..7ab87b498c 100644--- a/server/routes/universeBuilder.test.js+++ b/server/routes/universeBuilder.test.js@@ -563,6 +563,14 @@ describe('universe-builder routes', () => {expect(again.body.styleReferences.map((r) => r.id)).toEqual(['style-ref-b']);});+ it('DELETE /:id/style-references rejects an over-long referenceId', async () => {+ const app = buildApp();+ const c = await request(app).post('/api/universe-builder').send({ name: 'Refs' });+ const res = await request(app)+ .delete(`/api/universe-builder/${c.body.id}/style-references/${'x'.repeat(81)}`);+ expect(res.status).toBe(400);+ });+it('PATCH /:id still accepts a wholesale styleReferences replace (older clients + peer imports)', async () => {const app = buildApp();const c = await request(app).post('/api/universe-builder').send({diff --git a/server/services/universeBuilder/crud.js b/server/services/universeBuilder/crud.jsindex da4e205fff..6fbe4ab883 100644--- a/server/services/universeBuilder/crud.js+++ b/server/services/universeBuilder/crud.js@@ -684,8 +684,8 @@ export async function addStyleReference(id, reference, { adopt = null } = {}) {influences: resolveInfluences(adopt),} : {}),};- // A styleReferences (+ style-guide) patch carries no canon key, so skip the- // per-entry catalog projection the mutator path would otherwise run.+ // The patch above carries no canon key, so skip the per-entry catalog+ // projection the mutator path would otherwise run.}, { touchesCanon: false });}