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

🥕[Bug]: Validate requires optional sections #2542

Closed
JerryNixon opened this issue Jan 27, 2025 · 0 comments · Fixed by #2611
Closed

🥕[Bug]: Validate requires optional sections #2542

JerryNixon opened this issue Jan 27, 2025 · 0 comments · Fixed by #2611
Assignees
Labels
bug Something isn't working cri Customer Reported issue
Milestone

Comments

@JerryNixon
Copy link
Contributor

JerryNixon commented Jan 27, 2025

Validate requires optional sections

It appears that this bug only occurs when runtime.host is present. `

Validate requires runtime.host.cors to pass. This is an optional section.

In addition, validate requires runtime.host.authentication to pass - also optional.

Fortunately, dab start still works. This is an error in validate.

Super-simple configuration

This is as simple as it gets at this point.

{
  "$schema": "https://github.com/Azure/data-api-builder/releases/download/v1.3.19/dab.draft.schema.json",
  "data-source": {
    "database-type": "mssql",
    "connection-string": "xxx"
  },
  "runtime": {
    "host": {
      "authentication": {
        "provider": "StaticWebApps"
      }
    }
  },
  "entities": {}
}

Command

Just running standard validate.

dab validate -c dab-config.json

Result

Errors with runtime.host.cors. Looks like a .NET error to me.

c:\Temp\demo>dab validate -c dab-config.json
Information: Microsoft.DataApiBuilder 1.3.19
Information: User provided config file: dab-config.json
Information: Validating config file: dab-config.json
Loading config file from c:\Temp\demo\dab-config.json.
Information: Validating entity relationships.
Error: > Total schema validation errors: 1
> ObjectExpected: #/runtime.host.cors at 9:18

Updated Config

Just added in runtime.host.cors to demonstrate it is required for some reason.

{
  "$schema": "https://github.com/Azure/data-api-builder/releases/download/v1.3.19/dab.draft.schema.json",
  "data-source": {
    "database-type": "mssql",
    "connection-string": "xxx"
  },
  "runtime": {
    "host": {
      "cors": {
        "origins": [],
        "allow-credentials": false
      },
      "authentication": {
        "provider": "StaticWebApps"
      }
    }
  },
  "entities": {}
}

Re-run validate

This time it works, which is fine, but `runtime.host.cors should not be required.

c:\Temp\demo>dab validate -c dab-config.json
Information: Microsoft.DataApiBuilder 1.3.19
Information: User provided config file: dab-config.json
Information: Validating config file: dab-config.json
Loading config file from c:\Temp\demo\dab-config.json.
Information: The config satisfies the schema requirements.
Information: Validating entity relationships.
Information: Config is valid.

JSON Schema

The CORS section is NOT required. Neither is authentication by the way.

    "cors": {
      "type": "object",
      "description": "Configure CORS",
      "additionalProperties": false,
      "properties": {
        "origins": {
          "type": "array",
          "description": "Allowed origins",
          "items": {
            "type": "string"
          },
          "default": []
        },
        "allow-credentials": {
          "type": "boolean",
          "default": "false",
          "description": "Set value for Access-Control-Allow-Credentials header"
        }
      }
    },

Only happens when host is present.

If you remove the host section it works.

{
  "$schema": "https://github.com/Azure/data-api-builder/releases/download/v1.3.19/dab.draft.schema.json",
  "data-source": {
    "database-type": "mssql",
    "connection-string": "xxx"
  },
  "runtime": { },
  "entities": { }
}

Output

c:\Temp\demo>dab validate -c dab-config.json
Information: Microsoft.DataApiBuilder 1.3.19
Information: User provided config file: dab-config.json
Information: Validating config file: dab-config.json
Loading config file from c:\Temp\demo\dab-config.json.
Information: The config satisfies the schema requirements.
Information: Validating entity relationships.
Information: Config is valid.
@JerryNixon JerryNixon added bug Something isn't working cri Customer Reported issue triage issues to be triaged labels Jan 27, 2025
@JerryNixon JerryNixon changed the title [Bug]: start works but validate fails because of runtime.host.cors [Bug]: Validate requires optional sections Jan 27, 2025
@JerryNixon JerryNixon changed the title [Bug]: Validate requires optional sections 🥕[Bug]: Validate requires optional sections Feb 11, 2025
@abhishekkumams abhishekkumams self-assigned this Mar 4, 2025
@abhishekkumams abhishekkumams added this to the 1.5 milestone Mar 4, 2025
@abhishekkumams abhishekkumams removed the triage issues to be triaged label Mar 4, 2025
@sezal98 sezal98 assigned sezal98 and unassigned abhishekkumams Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cri Customer Reported issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants