{"record":{"id":"fe25db9e6f6ae977","repo":"mastra-ai/mastra","slug":"unable-to-use-unpublished-referenced-prompt-blocks","errorCode":null,"errorMessage":"Unable to use unpublished referenced prompt blocks: {ids}. Publish these prompt blocks and try again.","messagePattern":"Unable to use unpublished referenced prompt blocks: (.+?)\\. Publish these prompt blocks and try again\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/validate-agent-instructions.ts","lineNumber":92,"sourceCode":"      assertStoredResourceScope(result.value, scope);\n    } catch {\n      unresolvedIds.push(id);\n      continue;\n    }\n\n    if (result.value.status !== 'published' || !result.value.activeVersionId) {\n      unpublishedIds.push(id);\n    }\n  }\n\n  if (unresolvedIds.length > 0) {\n    throw new HTTPException(400, {\n      message: `Unable to verify referenced prompt blocks: ${unresolvedIds.join(', ')}. Resolve these references and try again.`,\n    });\n  }\n\n  if (unpublishedIds.length > 0) {\n    throw new HTTPException(400, {\n      message: UNPUBLISHED_REFERENCES_MESSAGE.replace('{ids}', unpublishedIds.join(', ')),\n    });\n  }\n}\n","sourceCodeStart":74,"sourceCodeEnd":97,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/validate-agent-instructions.ts#L74-L97","documentation":"HTTP 400 thrown by validateAgentInstructionReferences when referenced prompt blocks resolve but are not in 'published' status (or lack an activeVersionId). The server blocks agent creation/update/activation until the referenced blocks are published. The message lists the unpublished block IDs via UNPUBLISHED_REFERENCES_MESSAGE.","triggerScenarios":"CREATE_STORED_AGENT_ROUTE, UPDATE_STORED_AGENT_ROUTE, or ACTIVATE_AGENT_VERSION_ROUTE with instructions referencing draft/unpublished prompt blocks.","commonSituations":"Drafting an agent alongside newly drafted blocks and forgetting to publish them; a collaborator unpublished a block after the agent was written; CI deploying agents against blocks still in review.","solutions":["Publish the listed prompt blocks (give them a published status/active version), then retry.","Reference a published version of the block instead of the draft.","Remove or replace the unpublished references in the agent instructions."],"exampleFix":"// before\nawait fetch('/api/agents', { method: 'POST', body: JSON.stringify({ instructions: 'Use {{block:draft-block}}' }) });\n// after\nawait publishBlock('draft-block'); // ensure status === 'published' && activeVersionId\nawait fetch('/api/agents', { method: 'POST', body: JSON.stringify({ instructions: 'Use {{block:draft-block}}' }) });","handlingStrategy":"validation","validationCode":"const blocks = await fetch('/api/blocks').then(r => r.json());\nconst unpublished = refs.filter(id => {\n  const b = blocks.find(x => x.id === id);\n  return !b || b.status !== 'published' || !b.activeVersionId;\n});\nif (unpublished.length) throw new Error(`Publish first: ${unpublished.join(', ')}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Publish blocks before wiring them into agent instructions.","Add a CI step that verifies all referenced blocks are published.","Track block lifecycle status in your authoring UI and warn on draft references."],"tags":["http-400","validation","lifecycle","agent-instructions"],"backgroundTag":"unpublished-dependency","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}