nocobase/nocobase · error
Popup template not found
Error message
Popup template not found
What it means
resolveTemplateToUid in openViewActionExtensions resolves a popupTemplateUid parameter to the template's underlying popup model uid before opening the popup. It fetches the flowModelTemplates row by uid; if the row is missing or has no targetUid, it throws this localized error because there is no popup to open. Subsequently a resource-match check runs, but this specific throw happens first for the missing/malformed template.
Source
Thrown at packages/plugins/@nocobase/plugin-ui-templates/src/client-v2/openViewActionExtensions.tsx:909
onPopupScroll={(e) => {
const target = e?.target as HTMLElement | undefined;
if (!target) return;
if (target.scrollTop + target.clientHeight < target.scrollHeight - 24) return;
loadMore();
}}
dropdownMatchSelectWidth
getPopupContainer={() => document.body}
optionRender={renderTemplateSelectOption}
/>
);
}
const resolveTemplateToUid = async (ctx: FlowSettingsContext, params: any): Promise<void> => {
const templateUid = typeof params?.popupTemplateUid === 'string' ? params.popupTemplateUid.trim() : '';
if (!templateUid) return;
const tpl = await fetchTemplateByUid(ctx as any, templateUid);
if (!tpl?.targetUid) {
throw new Error(tWithNs(ctx, 'Popup template not found'));
}
const expected = resolveExpectedResourceInfo(ctx as any, params);
const expectedSource = resolveExpectedSourceResourceInfo(ctx as any, params);
const disabledReason = await getPopupTemplateDisabledReason(ctx as any, tpl, expected, expectedSource, params);
if (disabledReason) {
throw new Error(disabledReason);
}
params.uid = tpl.targetUid;
// collectionName / associationName / dataSourceKey 以模板为准(associationName 允许为空表示"非关系弹窗")
const tplDataSourceKey = normalizeStr(tpl?.dataSourceKey);
const tplCollectionName = normalizeStr(tpl?.collectionName);
const tplAssociationName = normalizeStr(tpl?.associationName);
if (tplDataSourceKey) {
params.dataSourceKey = tplDataSourceKey;
}
if (tplCollectionName) {View on GitHub (pinned to fa42722fef)
Solutions
- Re-create the popup template (or re-link the action) so popupTemplateUid points to an existing flowModelTemplates row with a non-empty targetUid.
- Check the flowModelTemplates table/collection for the uid and restore or fix the row's targetUid.
- Remove or repoint the popupTemplateUid param on the open-view action if the template is intentionally gone.
- When migrating environments, export/import template rows together with the schemas that reference them.
Example fix
// before: action params reference a deleted template
params: { popupTemplateUid: 'tpl-gone' } // -> throws 'Popup template not found'
// after: point at an existing template
params: { popupTemplateUid: 'tpl-123' } Defensive patterns
Strategy: validation
Validate before calling
// before opening a popup that uses a template
const tpl = await api.resource('flowModelTemplates').get({ filterByTk: templateId });
if (!tpl?.data?.targetUid) {
// template missing or dangling — re-link or recreate before the action runs
return message.error('Referenced popup template no longer exists.');
} Type guard
function isLiveTemplate(tpl: unknown): tpl is { targetUid: string } {
return !!tpl && typeof (tpl as any).targetUid === 'string' && (tpl as any).targetUid.length > 0;
} Try / catch
try {
await openViewWithTemplate(ctx, params);
} catch (e) {
if (e.message === 'Popup template not found') {
// offer to recreate the template or strip popupTemplateUid from params
} else throw e;
} Prevention
- Keep flowModelTemplates rows in sync across environments when exporting actions.
- Clean up actions referencing a template before deleting it.
- Validate popupTemplateUid values set manually in action params.
When it happens
Trigger: An open-view action configured with params.popupTemplateUid whose template row was deleted from flowModelTemplates, or whose targetUid is null/empty — e.g. the referenced popup template was removed by another user, an import/migration dropped rows, or the uid string is stale after a schema reset.
Common situations: Sharing actions/pages between environments where template uids don't exist in the target database; deleting a popup template that is still referenced by menu/open-view actions; restoring a backup where flowModelTemplates rows were not included; typos when setting popupTemplateUid manually in action params.
Related errors
- ${disabledReason}
- Popup template not found
- "${v}" does not exist
- [block-reference] flowModels uid must be a non-empty string
- Target block is invalid
AI-assisted analysis of nocobase/nocobase@fa42722fef (2026-09-01).
Data as JSON: /api/errors/53bf5c101c17e861.
Report an issue: GitHub.