Repository navigation
Description
Describe the bug
Hello, I was trying to use inheritance and sealed experimental features but, even with a new project, I always get these errors when using serverpod generate --experimental-features=all -w:
Found 2 issues.
Error on line 1, column 1 of lib\src\models\inventory\inventory_custom_item.spy.yaml: File path collision detected: This model and "/Users/me/Documents/Projects/dev/serverpod_experimental/serverpod_experimental_server/lib/src/models/inventory/inventory_custom_item.spy.yaml" would generate files at the same location. Please modify the path or filename to ensure each model generates to a unique location.
╷
1 │ ┌ class: InventoryCustomItem
2 │ │ extends: InventoryBaseItem
3 │ │ fields:
4 │ └ num: int
╵
Error on line 1, column 8 of lib\src\models\inventory\inventory_custom_item.spy.yaml: The class name "InventoryCustomItem" is already used by another model class.
╷
1 │ class: InventoryCustomItem
│ ^^^^^^^^^^^^^^^^^^^
╵
Found 2 issues.
Error on line 1, column 1 of c:/Users/me/Documents/Projects/dev/serverpod_experimental/serverpod_experimental_server/lib/src/models/inventory/inventory_custom_item.spy.yaml: File path collision detected: This model and "/C:/Users/me/Documents/Projects/dev/serverpod_experimental/serverpod_experimental_server/lib/src/models/inventory/inventory_custom_item.spy.yaml" would generate files at the same location. Please modify the path or filename to ensure each model generates to a unique location.
╷
1 │ ┌ class: InventoryCustomItem
2 │ │ extends: InventoryBaseItem
3 │ │ fields:
4 │ └ numb: int
╵
Error on line 1, column 8 of c:/Users/me/Documents/Projects/dev/serverpod_experimental/serverpod_experimental_server/lib/src/models/inventory/inventory_custom_item.spy.yaml: The class name "InventoryCustomItem" is already used by another model class.
╷
1 │ class: InventoryCustomItem
│ ^^^^^^^^^^^^^^^^^^^
╵
✗ Generating code (0.6s)
Incremental code generation complete.
Also --> The "extends" property is not allowed for class type. Valid keys are {class, table, managedMigration, serverOnly, fields, indexes}.Serverpod
and --> The "sealed" property is not allowed for class type. Valid keys are {class, table, managedMigration, serverOnly, fields, indexes}.Serverpod
even if I used --> serverpod generate --experimental-features=all
Thanks
To reproduce
create a project and try this:
class: InventoryBaseItem
sealed: true
fields:
serialId: String?
name: String
createdAt: DateTime, default = now
updatedAt: DateTime, default = now
class: InventoryCustomItem
extends: InventoryBaseItem
fields:
num: int
Try to use serverpod generate --experimental-features=all -w, change num in InventoryCustomItem to numb for example and save it.
Expected behavior
I expected the code to be generated successfully
Library version
2.3.1
Platform information
windows
Additional context
No response
How experienced are you with this library?
None
Are you interested in working on a PR for this?
- I want to work on this
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone 🚀
Activity
[-]Experimental Feature - serverpod generate --experimental-features=all -w is broken[/-][+]serverpod generate -w is broken[/+]Dario-Ciceri commentedon Jan 24, 2025
quick update: it doesn't work at all, I thought it was due to the experimental features but it doesn't work at all.
Only
serverpod generateandserverpod generate --experimental-features=allwork but don't if you use -wnow sealed class and extends are recognized but I don't know why
Dario-Ciceri commentedon Jan 24, 2025
There's also a problem with default values and inheritance
without the default values for createdAt and updatedAt the problem is gone.
[-]serverpod generate -w is broken[/-][+]serverpod generate -w is broken and issues with experimental features[/+][-]serverpod generate -w is broken and issues with experimental features[/-][+]serverpod generate -w is broken (when using Melos) and issues with experimental features[/+][-]serverpod generate -w is broken (when using Melos) and issues with experimental features[/-][+]serverpod generate -w is broken and issues with experimental features[/+]obiwanzenobi commentedon Feb 14, 2025
I think it is also related - having sealed class as a field type in (any) other model produces 2 errors in compile time:
SandPod commentedon Jun 19, 2025
@obiwanzenobi - Do we have issues for these? Otherwise it would be great if separate issues for these could be filed.
SandPod commentedon Sep 29, 2025
@Dario-Ciceri - Is this still an issue?
marcelomendoncasoares commentedon Nov 18, 2025
@obiwanzenobi This use case is now fixed! We changed the deserialization engine to support polymorphism on #4227 - so
fromJsonis no longer necessary - and PR #4238 fixed the missingcopyWithmethod for sealed classes.SandPod commentedon Nov 23, 2025
Closing this for now, please reopen if this is still an issue.