Desk Tool crashes with "Invalid path string" error when accessing post

7 replies
Last updated: Apr 11, 2021
Hello everyone, I'm having an issue with the studio when trying to access one of the posts I have created."The ‘Desk’ tool crashed"
The studio functions perfectly otherwise, only having an issue with one particular post which I don't mind deleting.

Stack trace:

Error: Invalid path string
    at Object.fromString (/static/js/app.bundle.js:162752:11)
    at findMostSpecificTarget (/static/js/app.bundle.js:263079:24)
    at <http://localhost:3333/static/js/app.bundle.js:262971:61>
    at Array.map (<anonymous>)
    at ConnectorsOverlay (/static/js/app.bundle.js:262964:54)
    at renderWithHooks (/static/js/vendor.bundle.js:17945:18)
    at updateFunctionComponent (/static/js/vendor.bundle.js:20176:20)
    at updateSimpleMemoComponent (/static/js/vendor.bundle.js:20114:10)
    at updateMemoComponent (/static/js/vendor.bundle.js:20003:14)
    at beginWork (/static/js/vendor.bundle.js:21824:16)
Component stack:

in ConnectorsOverlay (created by EnabledChangeConnectorRoot)
    in div (created by ForwardRef(ScrollContainer))
    in ForwardRef(ScrollContainer) (created by EnabledChangeConnectorRoot)
    in Tracker (created by EnabledChangeConnectorRoot)
    in EnabledChangeConnectorRoot (created by DocumentPane)
    in DialogProvider (created by DocumentPane)
    in div (created by KeyboardShortcutResponder)
    in KeyboardShortcutResponder (created by GetHookCollectionState)
    in GetHookCollectionState (created by RenderActionCollectionState)
    in RenderActionCollectionState (created by DocumentActionShortcuts)
    in DocumentActionShortcuts (created by DocumentPane)
    in LayerProvider (created by LegacyLayerProvider)
    in LegacyLayerProvider (created by DocumentPane)
    in DocumentPane (created by DocumentPaneProvider)
    in DocumentHistoryProvider (created by DocumentPaneProvider)
    in DocumentPaneProvider
    in StreamingComponent
    in StreamingComponent (created by Context.Consumer)
    in WithInitialValueWrapper (created by DeskToolPane)
    in DeskToolPane (created by DeskToolPanes)
    in SplitPaneWrapper (created by DeskToolPanes)
    in div (created by Pane)
    in Pane (created by SplitPane)
    in div (created by SplitPane)
    in SplitPane (created by PanesSplitController)
    in div (created by PanesSplitController)
    in div (created by Pane)
    in Pane (created by SplitPane)
    in div (created by SplitPane)
    in SplitPane (created by PanesSplitController)
    in div (created by PanesSplitController)
    in div (created by Pane)
    in Pane (created by SplitPane)
    in div (created by SplitPane)
    in SplitPane (created by PanesSplitController)
    in div (created by PanesSplitController)
    in PanesSplitController (created by DeskToolPanes)
    in PortalProvider (created by DeskToolPanes)
    in div (created by DeskToolPanes)
    in DeskToolPanes (created by DeskTool)
    in DeskTool (created by withRouter(DeskTool))
    in withRouter(DeskTool) (created by DeskToolPaneStateSyncer)
    in DeskToolPaneStateSyncer (created by DeskTool)
    in DeskToolFeaturesProvider (created by DeskTool)
    in DeskTool (created by RenderTool)
    in RenderTool (created by SchemaErrorReporter)
    in RouteScope (created by SchemaErrorReporter)
    in div (created by SchemaErrorReporter)
    in div (created by SchemaErrorReporter)
    in div (created by SchemaErrorReporter)
    in SchemaErrorReporter (created by DefaultLayout)
    in DefaultLayout (created by withRouter(DefaultLayout))
    in withRouter(DefaultLayout) (created by DefaultLayoutRoot)
    in RouterProvider (created by DefaultLayoutRoot)
    in LoginWrapper (created by DefaultLayoutRoot)
    in DefaultLayoutRoot (created by AppProvider)
    in div (created by styled.div)
    in styled.div (created by Box)
    in Box (created by Styled(Box))
    in Styled(Box) (created by Card)
    in Ge (created by ThemeProvider)
    in ThemeProvider (created by ThemeColorProvider)
    in ThemeColorProvider (created by Card)
    in Card (created by Styled(Card))
    in Styled(Card) (created by AppProvider)
    in SnackbarProvider (created by AppProvider)
    in ToastProvider (created by AppProvider)
    in LayerProvider (created by AppProvider)
    in PortalProvider (created by AppProvider)
    in UserColorManagerProvider (created by AppProvider)
    in AppProvider (created by SanityRoot)
    in Ge (created by ThemeProvider)
    in ThemeProvider (created by SanityRoot)
    in ZIndexProvider (created by SanityRoot)
    in SanityRoot
    in AppContainer
I was editing the schema and adding a custom image type in order to have a field for the alt text. I believe the issue begun after creating and adding that custom image type to the Post. Any suggestions on what I could possibly do?
AI Update

I can see you're experiencing an "Invalid path string" error in the Desk tool when trying to access a specific post. Based on the stack trace and your description, this is almost certainly related to the custom image type you added to your schema. The error is coming from ConnectorsOverlay which is part of the change tracking system in Sanity Studio, and the fromString function is failing to parse a path in your document.

Here are the steps to resolve this:

1. Delete the problematic document via API

Since you mentioned you don't mind deleting this post, the quickest solution is to delete it directly through the API or Vision tool:

Using Vision (in your Studio):

  • Go to the Vision tool in your Studio (usually at http://localhost:3333/vision)
  • Run this query to find your document:
*[_type == "post"] {_id, title}
  • Note the _id of the problematic post

Using the Management API:

You can use the Management API to delete the document. Get a token from manage.sanity.io with write permissions, then:

curl -X DELETE \
  'https://[YOUR-PROJECT-ID].api.sanity.io/v2021-06-07/data/mutate/[YOUR-DATASET]' \
  -H 'Authorization: Bearer [YOUR-TOKEN]' \
  -H 'Content-Type: application/json' \
  -d '{"mutations": [{"delete": {"id": "YOUR-DOCUMENT-ID"}}]}'

2. Fix your custom image schema

The root cause is likely in how you defined your custom image type. According to the Image Type documentation, make sure your custom image field follows this pattern:

{
  name: 'customImage',
  type: 'image',
  options: {
    hotspot: true
  },
  fields: [
    {
      name: 'alt',
      type: 'string',
      title: 'Alternative text',
    }
  ]
}

Common mistakes that cause path errors:

  • Adding nested objects incorrectly within the image type
  • Using reserved field names or invalid characters in field names
  • Improperly structured fields array
  • Missing or malformed _key values in array items

3. Clear your Studio's local cache

After fixing the schema:

# In your Studio directory
rm -rf node_modules/.cache
npm run dev

4. If you want to recover the document

If you need to save the content before deleting:

  1. Export the document via Vision: *[_id == "YOUR-DOCUMENT-ID"][0]
  2. Copy the output
  3. Look for the image field and check if there's malformed data (empty strings, missing required properties, etc.)
  4. Manually fix the data structure
  5. Re-import it using a mutation after fixing your schema

The invalid path is likely in the image field's internal structure - possibly an empty or malformed _key value, an incorrectly nested field path, or a field name that doesn't match your schema definition.

Let me know if deleting the document and fixing your schema resolves the issue!

Show original thread
7 replies
Hey there! Mind sharing the schema so we can take a look?
Of course.

import createSchema from 'part:@sanity/base/schema-creator'


import schemaTypes from 'all:part:@sanity/base/schema-type'


import blockContent from './blockContent'

import category from './category'

import post from './post'

import author from './author'

import cstmImage from './cstmImage'

import comment from './comment'


export default createSchema({

name: 'default',

types: schemaTypes.concat([

post,

author,

category,

comment,

cstmImage,

blockContent,

]),

})
user M
Could you please help me at least delete that post?I tried to do it via queries in Vision on my local sanity studio but it doesn't seem to work.
I'm using the correct id which I fetched by another query so that isn't the problem.
Am I doing something wrong or is this not the way I am supposed to do it?


{

"mutations": [

{

"delete": {

"id": "drafts.2f763dc5-aaa5-4c50-8e89-5991fa12118c"

}

}

]

}
Hi Aniruddha. Mutations can’t be run from Vision so you’d need to do this from the CLI, using the JavaScript (or PHP) client, or the HTTP API. You could use a write token and the command above should work in a program like Insomnia or Postman.
Here’s how you could do it in Insomnia.
1. Create a write token at
manage.sanity.io .2. Create a new POST request in Insomnia.
3. Set the URL to
https://<PROJECT_ID>.<http://api.sanity.io/v1/data/mutate/<DATASET|api.sanity.io/v1/data/mutate/<DATASET>>
. For example, it might look like
<https://32ghjcl8.api.sanity.io/v1/data/mutate/production>
.4. Paste your code above into the JSON tab.
5. Add your token under the Bearer tab.
6. You
might need to set the Content-Type to application/json under the Header tab.7. Press Send.
To use the CLI, go to your studio directory in your terminal and enter
sanity documents delete drafts.2f763dc5-aaa5-4c50-8e89-5991fa12118c
(that’s a copy-and-paste from your post above, so double-check it’s correct).
Thank you so much
user A
.It worked :)

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?