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

Misleading error message from incomplete model #743

Closed
kggilmer opened this issue Mar 19, 2021 · 1 comment · Fixed by #775
Closed

Misleading error message from incomplete model #743

kggilmer opened this issue Mar 19, 2021 · 1 comment · Fixed by #775

Comments

@kggilmer
Copy link
Contributor

kggilmer commented Mar 19, 2021

A model with @xmlFlattened attrubutes that is missing the referenced structure emits a "trait deprecated" error.

Source model:

namespace com.test

use aws.protocols#restXml

@restXml
service Example {
    version: "1.0.0",
    operations: [
        Foo
    ]
}

    @http(method: "POST", uri: "/foo")
    operation Foo {
        input: FooRequest,
        output: FooRequest
    }  
    
    @xmlName("CustomFooRequest")
    structure FooRequest {
        @xmlFlattened
        listVal: ListOfString,
        @xmlFlattened
        mapVal: MapOfInteger
    }

Expected error:

Only the error about the fact that `ListOfString` and/or `MapOfInteger` are undefined.  The deprecated trait error seems to be incorrect.

Actual Error:

[ERROR] com.test#FooRequest$listVal: Trait `xmlFlattened` cannot be applied to `com.test#FooRequest$listVal`. This trait may only be applied to shapes that match the following selector: :is(structure, union) > :test(member > :test(collection, map)) | TraitTarget test.smithy:24:30
[ERROR] com.test#FooRequest$listVal: member shape targets an unresolved shape `com.test#ListOfString` | Target test.smithy:25:1

Side note: when missing shapes are added there are no errors.

@srchase
Copy link
Contributor

srchase commented Mar 19, 2021

The deprecated trait error is being emitted for the use of the @restXml trait. It's unrelated to the @xmlFlattened trait use.

The broken references, i.e. the missing shape, do result in some confusing errors. Ideally, no further validation would run after broken references are found, that'd eliminate the TraitTarget error in this instance.

mtdowling added a commit that referenced this issue Apr 18, 2021
We previously would continue to perform more granular semantic model
validation even after an ERROR was encountered while loading the model.
If an ERROR is encountered while loading a model, then it is very likely
that it can cause a flurry of unrelated validation events to emit errors
that would only obscure the root cause of the issue.

This commit updates model validation to stop if an ERROR occurred while
loading models, if a model has broken shape references, if a shape
target targets an invalid shape, or if a resource hierarchy is
recursive. This update required various "kitchen-sink" style tests to be
updated to account for the new validation behavior.

Closes #743
mtdowling added a commit that referenced this issue Apr 19, 2021
We previously would continue to perform more granular semantic model
validation even after an ERROR was encountered while loading the model.
If an ERROR is encountered while loading a model, then it is very likely
that it can cause a flurry of unrelated validation events to emit errors
that would only obscure the root cause of the issue.

This commit updates model validation to stop if an ERROR occurred while
loading models, if a model has broken shape references, if a shape
target targets an invalid shape, or if a resource hierarchy is
recursive. This update required various "kitchen-sink" style tests to be
updated to account for the new validation behavior.

Closes #743
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants