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

Compose spec import error #82

Open
AndrewO opened this issue May 9, 2024 · 1 comment
Open

Compose spec import error #82

AndrewO opened this issue May 9, 2024 · 1 comment

Comments

@AndrewO
Copy link

AndrewO commented May 9, 2024

Following the Convert JSON Schema with the current compose schema (as of this commit), cue import raises the following error:

% cue import -f -p compose -l '#ComposeSpec:' compose-spec.json

constraint not allowed because type object is excluded:
    ./compose-spec.json:471:11

The offending JSON Schema section is below, specifically the "patternProperties": {"^x-": {}}.

    "development": {
      "id": "#/definitions/development",
      "type": ["object", "null"],
      "properties": {
        "watch": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["path", "action"],
            "properties": {
              "ignore": {"type": "array", "items": {"type": "string"}},
              "path": {"type": "string"},
              "action": {"type": "string", "enum": ["rebuild", "sync", "sync+restart"]},
              "target": {"type": "string"}
            }
          },
          "additionalProperties": false,
          "patternProperties": {"^x-": {}}
        }
      }

Removing that line (and the comma on the line above) worked around the issue. I'm not sure what a more correct fix would be.

@verdverm
Copy link
Member

verdverm commented May 9, 2024

Hmm, this seems like an error in the schema.json file

  1. There are many similar fields that import fine
  2. If you move the tow fields up, to be inside the items object, it also works
    "development": {
      "id": "#/definitions/development",
      "type": ["object", "null"],
      "properties": {
        "watch": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["path", "action"],
            "properties": {
              "ignore": {"type": "array", "items": {"type": "string"}},
              "path": {"type": "string"},
              "action": {"type": "string", "enum": ["rebuild", "sync", "sync+restart"]},
              "target": {"type": "string"}
            },
            "additionalProperties": false,
            "patternProperties": {"^x-": {}}
          }
        }
      }
    },

Doing so matches another type on line 577

    "generic_resources": {
      "id": "#/definitions/generic_resources",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "discrete_resource_spec": {
            "type": "object",
            "properties": {
              "kind": {"type": "string"},
              "value": {"type": "number"}
            },
            "additionalProperties": false,
            "patternProperties": {"^x-": {}}
          }
        },
        "additionalProperties": false,
        "patternProperties": {"^x-": {}}
      }
    },

So maybe this is a win for CUE?

I'd ask on the source repository, show them this issue, and see what they say.

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

2 participants