{"record":{"id":"778279e047101244","repo":"stablyai/orca","slug":"failed","errorCode":"failed","errorMessage":"Linear relation creation failed","messagePattern":"Linear relation creation failed","errorType":"error_code","errorClass":"LinearWriteFailure","httpStatus":null,"severity":"error","filePath":"src/main/linear/issue-relation-mutation.ts","lineNumber":46,"sourceCode":"const DELETE_RELATION_MUTATION = `\n  mutation OrcaLinearDeleteIssueRelation($id: String!) {\n    issueRelationDelete(id: $id) { success }\n  }\n`\n\nexport async function createLinearIssueRelation(\n  client: LinearClient,\n  input: { issueId: string; relatedIssueId: string; type: string }\n): Promise<RawRelationNode> {\n  const raw = await runRelationMutation(() =>\n    client.client.rawRequest<RelationMutationResponse, Record<string, unknown>>(\n      CREATE_RELATION_MUTATION,\n      { input }\n    )\n  )\n  const created = raw.data?.issueRelationCreate\n  if (created?.success !== true || !created.issueRelation) {\n    throw new LinearWriteFailure('failed', 'Linear relation creation failed')\n  }\n  return created.issueRelation\n}\n\nexport async function deleteLinearIssueRelation(\n  client: LinearClient,\n  relationId: string\n): Promise<void> {\n  const raw = await runRelationMutation(() =>\n    client.client.rawRequest<RelationMutationResponse, Record<string, unknown>>(\n      DELETE_RELATION_MUTATION,\n      { id: relationId }\n    )\n  )\n  if (raw.data?.issueRelationDelete?.success !== true) {\n    throw new LinearWriteFailure('failed', 'Linear relation removal failed')\n  }\n}","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/linear/issue-relation-mutation.ts#L28-L64","documentation":"Thrown by createLinearIssueRelation when the GraphQL issueRelationCreate response lacks success===true or lacks the created issueRelation node. The mutation reached Linear and came back, but Linear reported failure (or returned an unexpected shape). Encoded as LinearWriteFailure kind 'failed'.","triggerScenarios":"Linear rejects the relation input — invalid issueId/relatedIssueId, an unsupported relation type, a cyclic/disallowed relation, or a permission error returned as success:false. Also when the schema changes and issueRelationCreate no longer returns the expected node fields.","commonSituations":"User links two issues across teams/permission boundaries. Relation type string is wrong (case-sensitive). Issue was deleted between selection and create. API token lacks write scope for relations.","solutions":["Verify issueId and relatedIssueId are valid, existing Linear issue ids.","Confirm the relation type is one Linear accepts for that issue pair.","Ensure the API token has write permission on both issues.","Inspect raw.data?.issueRelationCreate for Linear's error detail; fall back to the Linear web UI if the SDK hides it."],"exampleFix":"// before\nawait createLinearIssueRelation(client, { issueId, relatedIssueId, type: 'BLOCKS' })\n// after\nconst validTypes = ['blocks','isBlockedBy','duplicate','relatesTo']\nif (!validTypes.includes(type)) throw new Error('bad type')\nawait createLinearIssueRelation(client, { issueId, relatedIssueId, type })","handlingStrategy":"try-catch","validationCode":"const validTypes = ['blocks','isBlockedBy','duplicate','relatesTo']\nif (!validTypes.includes(input.type) || !input.issueId || !input.relatedIssueId) throw new Error('invalid relation input')","typeGuard":"function isLinearWriteFailure(e: unknown): e is LinearWriteFailure {\n  return e instanceof Error && (e as LinearWriteFailure).name === 'LinearWriteFailure'\n}","tryCatchPattern":"try { return await createLinearIssueRelation(client, input) }\ncatch (e) {\n  if (e instanceof LinearWriteFailure && e.kind === 'failed') { await refreshRelations(input.issueId); throw e }\n  throw e\n}","preventionTips":["Validate relation type and both issue ids before calling.","Ensure the token has relation write scope on both issues.","Surface raw.data?.issueRelationCreate details for Linear's rejection reason."],"tags":["linear","relation","graphql","write-failure"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}