Skip to content

serverpod generate -w is broken and issues with experimental features #3173

Closed

Description

@Dario-Ciceri

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

Activity

  1. added
    bug
    on Jan 24, 2025
  2. changed the title [-]Experimental Feature - serverpod generate --experimental-features=all -w is broken[/-] [+]serverpod generate -w is broken[/+] on Jan 24, 2025
  3. Dario-Ciceri commented on Jan 24, 2025

    @Dario-Ciceri
    Author

    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 generate and serverpod generate --experimental-features=all work but don't if you use -w

    now sealed class and extends are recognized but I don't know why

  4. Dario-Ciceri commented on Jan 24, 2025

    @Dario-Ciceri
    Author

    There's also a problem with default values and inheritance

    abstract class InventoryCustomItem extends _i1.InventoryItem
        implements _i2.TableRow, _i2.ProtocolSerialization {
      InventoryCustomItem._({
        this.id,
        super.serialId,
        required super.name,
        DateTime? createdAt,
        DateTime? updatedAt,
        required this.customFields,
      })  : createdAt = createdAt ?? DateTime.now(),
            updatedAt = updatedAt ?? DateTime.now();
    
    'createdAt' isn't a field in the enclosing class.
    Try correcting the name to match an existing field, or defining a field named 'createdAt'.
    
    'updatedAt' isn't a field in the enclosing class.
    Try correcting the name to match an existing field, or defining a field named 'updatedAt'.
    

    without the default values for createdAt and updatedAt the problem is gone.

  5. changed the title [-]serverpod generate -w is broken[/-] [+]serverpod generate -w is broken and issues with experimental features[/+] on Jan 24, 2025
  6. changed the title [-]serverpod generate -w is broken and issues with experimental features[/-] [+]serverpod generate -w is broken (when using Melos) and issues with experimental features[/+] on Jan 26, 2025
  7. changed the title [-]serverpod generate -w is broken (when using Melos) and issues with experimental features[/-] [+]serverpod generate -w is broken and issues with experimental features[/+] on Jan 26, 2025
  8. added
    area: cli
    on Feb 11, 2025
  9. obiwanzenobi commented on Feb 14, 2025

    @obiwanzenobi
    Contributor

    I think it is also related - having sealed class as a field type in (any) other model produces 2 errors in compile time:

    • missing fromJson of sealed class field (there should be some general fromJson that should find proper implementation and deserialize it)
    • missing copyWith of sealed class field
  10. moved this from Next 🌟 to Bugs 🐞 in Serverpod Frameworkson Jun 16, 2025
  11. SandPod commented on Jun 19, 2025

    @SandPod
    Contributor

    @obiwanzenobi - Do we have issues for these? Otherwise it would be great if separate issues for these could be filed.

  12. SandPod commented on Sep 29, 2025

    @SandPod
    Contributor

    @Dario-Ciceri - Is this still an issue?

  13. added
    in triage
    on Sep 29, 2025
  14. marcelomendoncasoares commented on Nov 18, 2025

    @marcelomendoncasoares
    Collaborator

    I think it is also related - having sealed class as a field type in (any) other model produces 2 errors in compile time:

    • missing fromJson of sealed class field (there should be some general fromJson that should find proper implementation and deserialize it)
    • missing copyWith of sealed class field

    @obiwanzenobi This use case is now fixed! We changed the deserialization engine to support polymorphism on #4227 - so fromJson is no longer necessary - and PR #4238 fixed the missing copyWith method for sealed classes.

  15. SandPod commented on Nov 23, 2025

    @SandPod
    Contributor

    Closing this for now, please reopen if this is still an issue.

  16. moved this from Backlog 🗂️ to Done 🚀 in Serverpod Frameworkson Nov 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: clibugin triage

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions