Describe the bug
When using @sanity/assist to define a field action, the client fails to find the schemaId for documents. Hardcoding the schemaId to "page" or using the one provided in props (_.schemas.ww) always results in a Not Found error.
To Reproduce
Steps to reproduce the behavior:
- Install
@sanity/assist and @sanity/document-internationalization plugins.
- Use the following field action configuration:
fieldActions: {
title: "SEO Actions",
useFieldActions: (props) => {
const {
actionType,
schemaId,
documentIdForAction,
path,
getConditionalPaths,
} = props;
const client = useClient({ apiVersion: "vX" });
return useMemo(() => {
if (actionType === "field") {
if (path[0] !== "seo") return [];
return [
defineAssistFieldAction({
title: "Generate SEO",
onAction: async () => {
await client.agent.action.generate({
schemaId, // or hardcoded "page"
documentId: documentIdForAction,
instruction: `
Generate SEO metadata for this document's SEO field.
`,
instructionParams: {
doc: { type: "document" },
field: { type: "field", path },
},
target: { path },
conditionalPaths: { paths: getConditionalPaths() },
});
},
}),
];
}
return [];
}, [actionType, path, client, schemaId, documentIdForAction, getConditionalPaths]);
},
}
- Attempt to trigger the action on a page document in the studio.
Expected behavior
The action should execute and generate SEO metadata without errors.
Observed behavior
Error thrown:
Failed to execute action
ClientError: Not Found - Schema for schemaId 'page' could not be found
Even hardcoding the schemaId does not resolve the issue.
Additional context
- Using the documentInternationalization plugin.
- Project has two datasets: production and staging.
- I18N_DOCUMENT_TYPES = ["footer", "home", "menu", "page"].
- The documentIdForAction exists and is valid.
- Using React 18 and latest Sanity v4 CLI + studio.
Describe the bug
When using
@sanity/assistto define a field action, the client fails to find theschemaIdfor documents. Hardcoding theschemaIdto"page"or using the one provided in props (_.schemas.ww) always results in aNot Founderror.To Reproduce
Steps to reproduce the behavior:
@sanity/assistand@sanity/document-internationalizationplugins.Expected behavior
The action should execute and generate SEO metadata without errors.
Observed behavior
Error thrown:
Even hardcoding the schemaId does not resolve the issue.
Additional context