Skip to content
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

Directly constrained lists containing indirectly constrained aggregate shapes generate uncompilable code #3885

Open
drganjoo opened this issue Oct 18, 2024 · 0 comments · May be fixed by #3894
Labels
high-priority High priority issue server Rust server SDK

Comments

@drganjoo
Copy link
Contributor

drganjoo commented Oct 18, 2024

Issue: Code generation fails for directly constrained list with indirectly constrained aggregate shapes

When generating code for a model where a list contains a non-constrained map with a constrained key, an error occurs during server-side code generation.

operation SampleOp {
    input := {
        items: ItemList
    }
    errors: [ValidationException]
}
@length(min: 1, max: 100)
list ItemList {
    member: Item
}
map Item {
    key: ItemName,
    value: ItemDescription
}
@length(min: 0, max: 65535)
string ItemName
string ItemDescription

This also happens if the constrained list contains another indirectly constrained list as a member.

operation SampleOp {
    input := {
        items: ItemList
    }
    errors: [ValidationException]
}
@length(min: 1, max: 100)
list ItemList {
    member: Item
}
list Item {
    member: ItemName,
}
@length(min: 0, max: 65535)
string ItemName
string ItemDescription

Code Generation Error:

error[E0277]: the trait bound `ItemList: TryFrom<Vec<ItemConstrained>>` is not satisfied
  --> src/unconstrained.rs:39:13
   |
39 |             Self::try_from(inner)
   |             ^^^^ the trait `From<Vec<ItemConstrained>>` is not implemented for `ItemList`, which is required by `ItemList: TryFrom<Vec<ItemConstrained>>`
   |
@drganjoo drganjoo added server Rust server SDK high-priority High priority issue labels Oct 18, 2024
@drganjoo drganjoo changed the title Fix code generation error for lists containing maps with constrained keys Directly constrained lists containing indirectly constrained aggregate shapes generate uncompilable code Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high-priority High priority issue server Rust server SDK
Projects
None yet
1 participant