Issue with loading a document in Sanity Studio after creating it via a POST request.

5 replies
Last updated: May 6, 2020
Hi,I'm working on implementing internationalization via this great package,
sanity-plugin-intl-input .When selecting a language that does not yet exist, it routes to the new document, and a POST request is sent with the new document, and returnDocument=true is set.
The new document is returned in the response, and the document is created. But the Sanity Studio loads the attached image.
Refreshing the studio fetches the document properly.
Any idea what might be wrong, or where to start looking?
AI Update

This sounds like a routing issue where the Studio is incorrectly navigating after creating a new language document. When you create a new language version, the document is successfully created (as confirmed by the fact that refreshing works), but the Studio's navigation logic is somehow routing to an image asset instead of the newly created document.

Where to Start Troubleshooting

1. Check the network response Open your browser DevTools Network tab and find the POST request that creates the document. Verify:

  • The response contains the correct document structure
  • The _id field is what you expect
  • Look at what the plugin is doing with the returned document data

2. Inspect the URL after creation When the image loads instead of the document, check the URL bar. This will tell you what ID the Studio is trying to route to—it's likely showing an image asset ID rather than your document ID.

3. Check your document schema If your document type includes image fields, there might be an issue with how the plugin is extracting the document ID from the response. It could be accidentally grabbing an image asset reference instead.

4. Look at the plugin's routing logic Since sanity-plugin-intl-input is a community plugin, check its GitHub repository for:

  • Similar issue reports
  • Recent updates or fixes
  • The source code where it handles navigation after document creation

Potential Workarounds

Since refreshing works (confirming the document is created successfully), this is purely a client-side navigation issue in the Studio. Here are some approaches:

Option 1: Force a router refresh You might be able to patch the plugin or add custom logic to trigger a router refresh after document creation, similar to what the manual refresh does.

Option 2: Check for plugin updates Make sure you're on the latest version of sanity-plugin-intl-input that's compatible with your Studio version. There may have been fixes for this specific issue.

Option 3: Consider alternative solutions If this issue persists, you might want to evaluate other internationalization approaches. Sanity offers several localization strategies, including the official @sanity/document-internationalization plugin (developed by Simeon Griggs and Liam Martens). Note that these are different plugins with different approaches—not direct replacements—so migration would require evaluation of whether the architecture fits your needs.

Debug Steps

Try logging what's happening in the plugin after the POST request:

  • What document ID is being extracted from the response?
  • What URL is being constructed for navigation?
  • Is there any transformation of the document data that might be causing the confusion?

The fact that this happens specifically when returnDocument=true suggests the issue is in how the plugin processes the returned document data to construct the navigation URL. The image reference is likely being picked up from somewhere in that returned document structure.

Hi Kenneth, what’s the URL at the moment it shows the error you attached? Does the URL change when you refresh?
The error suggests it cannot get the schema for the type name (
scenario
in this case). But considering it loads successfully on refresh, it seems like this schema type does in fact exist. Could you confirm that
scenario
is a document type, not an object?
<http://localhost:3333/ss-1116/desk/scenario;04fcb4e9-9453-40b3-a951-e79ff085c644__i18n_fr-FR>
The URL is the same when I refresh the page.

Thats correct,
scenario
is a document type.
To add some more info, I can see that after the POST,a bunch of GET requests with the query
[*[_id in ["drafts.04fcb4e9-9453-40b3-a951-e79ff085c644__i18n_fr-FR","04fcb4e9-9453-40b3-a951-e79ff085c644__i18n_fr-FR"]][0...2]{_id,_rev,_type,_type}][0...1]
is run, with an empty [] as result.
After this, a GET request against
https://{APPID}.<http://api.sanity.io/v1/data/doc/ss-1116/drafts.04fcb4e9-9453-40b3-a951-e79ff085c644__i18n_fr-FR,04fcb4e9-9453-40b3-a951-e79ff085c644__i18n_fr-FR|api.sanity.io/v1/data/doc/ss-1116/drafts.04fcb4e9-9453-40b3-a951-e79ff085c644__i18n_fr-FR,04fcb4e9-9453-40b3-a951-e79ff085c644__i18n_fr-FR>
runs and successfully returns the new document. Type still
scenario
as expected.
I seem to have found the problem. It was the structure builder that created the problems. After changing it to how the intl-plugin expects the content to be, it seems to work 🙂
Thanks for digging further into this issue! Glad you figured out what the problem was, because it wasn’t that obvious from the error or the strange behaviour without vs. with refresh. Was the information you needed to resolve this already included in the plugin readme? https://github.com/LiamMartens/sanity-plugin-intl-input (if not, maybe we can ask Liam to add it) 🙂
Not sure honestly. What I did to solve it was to take the filter used inside the function to get a filtered list, and manually adding it to the documents we are adding translations to.Only thing not working now is the "side-by-side" view, not sure if that's related.

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?