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

Incorrect reference validation #2550

Open
rpash opened this issue Mar 3, 2025 · 0 comments
Open

Incorrect reference validation #2550

rpash opened this issue Mar 3, 2025 · 0 comments

Comments

@rpash
Copy link

rpash commented Mar 3, 2025

In the case of a simple model like below

$version: "2"

namespace my.service

resource Message {
    identifiers: {
        id: String
    }
    properties: {
        message: String
    }
    create: CreateMessage
}

operation CreateMessage {
    output: CreateMessageOutput
}

structure CreateMessageOutput for Message {
    $id
    $message
}

Smithy validators report this warning:

MemberShouldReferenceResource: This member appears to reference the following resources without being included in a `@references` trait: [`my.service#Message`]

We can clearly see that CreateMessageOutput is referencing Message, but the member which the validator is complaining about appears in the identifiers section not the properties section of the resource. It appears the validator does not consider the resource's identifiers in its checks. I would expect this to be completely a valid structure since correct code is generated and the correct type is deduced for CreateMessageOutput.id from this model code. This seems like a false positive and it is extremely clunky to have this code below which references Message twice to get this warning to disappear:

@references([
    {
        // Needed for ID reference
        resource: Message
    }
])
structure CreateMessageOutput for Message {
    $id
    $message
}
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

No branches or pull requests

1 participant