paperclipai/paperclip · error

Only the example author can change decision training example

Error message

Only the example author can change decision training examples

What it means

Ownership gate in requireExampleOwner: the authenticated board user is not the user who created this decision-training example, and only the author may edit or delete examples, so the mutation is refused with 403.

Source

Thrown at server/src/routes/decision-training.ts:46

  if (!req.actor.userId) {
    res.status(403).json({ error: "Board user context required" });
    return null;
  }
  return req.actor.userId;
}

function parseExampleId(req: Request, res: Response) {
  const parsed = exampleIdSchema.safeParse(req.params.id);
  if (!parsed.success) {
    res.status(404).json({ error: "Decision training example not found" });
    return null;
  }
  return parsed.data;
}

function requireExampleOwner(res: Response, userId: string, createdByUserId: string) {
  if (userId !== createdByUserId) {
    res.status(403).json({ error: "Only the example author can change decision training examples" });
    return false;
  }
  return true;
}

export function decisionTrainingRoutes(db: Db) {
  const router = Router();
  const svc = decisionTrainingService(db);

  router.post(
    "/companies/:companyId/decision-training",
    validate(createSchema),
    async (req, res) => {
      const companyId = req.params.companyId as string;
      assertCompanyAccess(req, companyId);
      const userId = requireHumanUser(req, res);
      if (!userId) return;

View on GitHub (pinned to a7e689b3c3)

Solutions

  1. This is an authorization rule, not a bug: perform the action with an actor that satisfies the stated constraint (board user, the owning agent, or an in-scope resource).
  2. If access should be allowed, verify the actor's credentials/company scope and the resource's ownership before retrying.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/src/routes/decision-training.ts:46 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@a7e689b3c3 (2026-08-18). Data as JSON: /api/errors/87e623bea2cc52a3. Report an issue: GitHub.