-
Notifications
You must be signed in to change notification settings - Fork 445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: ensures singleworkspace falls back to the name 'default' as expected in all contexts #8228
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
…defined in config for all contexts
55a0bb3
to
2b2071d
Compare
No changes to documentation |
Component Testing Report Updated Jan 9, 2025 4:26 PM (UTC) ❌ Failed Tests (1) -- expand for details
|
⚡️ Editor Performance ReportUpdated Thu, 09 Jan 2025 16:29:25 GMT
Detailed information🏠 Reference resultThe performance result of
🧪 Experiment resultThe performance result of this branch
📚 Glossary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch! Thank you @snorrees
Description
I honestly cant tell you how this slipped through when building Start in Create, but here we go:
Turns out that if you
definedConfig({})
without providing a name, thenuseWorkspace().name
will be undefined.In other contexts, the name will be
default
(for instance when building the create manifest).This is not a problem in multi-workspace settings, where
name
is required for each config. I suspect I've overindexed on testing multi-workspace.In short, this ensures that resolved workspace summary and unstable_sources gets a name, by setting single workspace name to
'default'
as soon as possible, when it is missing.The bug occurs in WorkspaceLoader, where the values in
unstable_sources
are spread over the current workspace config (the former had undefined name property, the latter the value'default'
)Some relevant lines:
sanity/packages/sanity/src/core/studio/workspaceLoader/WorkspaceLoader.tsx
Line 60 in fb1cf5b
sanity/packages/sanity/src/core/config/prepareConfig.tsx
Line 204 in fb1cf5b
sanity/packages/sanity/src/core/config/prepareConfig.tsx
Line 182 in fb1cf5b
Current consequence
This bug specifically breaks "Start in Create" integration for single workspace studios without
name
.Current workaround:
defineConfig({name: 'default, /* everything else */})
More context
After checking what I've used to test, it turns out my single workspace repos all have
name: 'default'
set in config.So this has been a problem for templates or configurations that have not set
name
.The config we have in the core tempaltes DO have name, but I suspect some of our next templates dont.
What to review
Is there any problems with this approach?
For the record, the return value of useWorkspace().name is defined as required, so from a type perspective this is not a breaking change, but a bugfix.
Testing
The changed unit test breaks if the code change is reverted. I think it covers everything.
Notes for release
N/A