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

Dangling type $ref in Schema #1820

Closed
t0yv0 opened this issue Feb 15, 2022 · 2 comments
Closed

Dangling type $ref in Schema #1820

t0yv0 opened this issue Feb 15, 2022 · 2 comments
Labels
kind/bug Some behavior is incorrect or out of spec resolution/duplicate This issue is a duplicate of another issue

Comments

@t0yv0
Copy link
Member

t0yv0 commented Feb 15, 2022

Hello!

  • Vote on this issue by adding a 👍 reaction
  • To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already)

Issue details

As I am building an AWS codegen for a new Pulumi language I encountered a peculiarity that's not obvious.

curl https://raw.githubusercontent.com/pulumi/pulumi-aws/v4.37.3/provider/cmd/pulumi-resource-aws/schema.json -o ~/schemas/pulumi-aws-v4.37.3.json

jq '.resources["aws:iam/instanceProfile:InstanceProfile"].stateInputs.properties.role' ~/schemas/pulumi-aws-v4.37.3.json

{
  "type": "string",
  "oneOf": [
    {
      "type": "string"
    },
    {
      "type": "string",
      "$ref": "#/types/aws:iam/role:Role"
    }
  ],
  "description": "Name of the role to add to the profile.\n"
}

jq '.types["aws:iam/role:Role"]' ~/schemas/pulumi-aws-v4.37.3.json
null

jq '.resources["aws:iam/role:Role"].properties.uniqueId' ~/schemas/pulumi-aws-v4.37.3.json 
{
  "type": "string",
  "description": "Stable and unique string identifying the role.\n"
}

You may notice that the "$ref" in the example does not have a corresponding entry in the .types; it does have a corresponding entry in .resources though. I wonder if this is a mistake in the schema - should we catch these by the schema checker? Or something meaningful is intended here?

Also, if the reference was not dangling but the type was defined, I'm wondering what the form that uses both "type" and "$ref" signify. That seemed malformed and I could not find docs about this.

    {
      "type": "string",
      "$ref": "#/types/aws:iam/role:Role"
    }

The C# codegen simply deals with this as Input which is also what I can do, but it's confusing.

Steps to reproduce

Expected:
Actual:

@t0yv0
Copy link
Member Author

t0yv0 commented Feb 18, 2022

OK I think this may be something slightly undocumented referred to as "relaxed enums". The form is relaxed enum form. Still I think the dangling ref is an error.

@mikhailshilkov mikhailshilkov added the resolution/duplicate This issue is a duplicate of another issue label Nov 2, 2023
@mikhailshilkov
Copy link
Member

This is tracked more broadly in #2565, I'll close this issue as a dupe

@mikhailshilkov mikhailshilkov closed this as not planned Won't fix, can't repro, duplicate, stale Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/duplicate This issue is a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants