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]: Biovalidator can't detect local schema ID - "Empty schema $id" #74

Open
M-casado opened this issue Jun 24, 2024 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@M-casado
Copy link
Contributor

Bug summary

Biovalidator complains about an empty $id in a local schema with a proper $id

Technical details

  • Biovalidator branch used for installation main
  • node v16.13.0
  • npm v8.6.0
  • OS: WSL2

To reproduce

  1. Create a simple JSON Schema with a $id field as follows:
{
    "$schema": "https://json-schema.org/draft/2019-09/schema",
    "$id": "https://raw.githubusercontent.com/EbiEga/ega-metadata-schema/main/schemas/test.json",
    "type": "object",
    "$async": true,
    "required": ["test" ],
    "additionalProperties": false,
    "properties": {
      "test": {
        "type": "string",
        "enum": ["test"]
      }
    }      
  }
  1. Try to compile the schema using -r at launch of a Biovalidator server:
$ node biovalidator -r "schema_test/test.json"
2024-06-24T16:29:42.041Z [info] Custom keywords successfully added. Number of custom keywords: 5
2024-06-24T16:29:42.042Z [info] Compiling local schema from: schema_test/test.json
2024-06-24T16:29:42.048Z [info] Adding compiled local schema to cache: https://raw.githubusercontent.com/EbiEga/ega-metadata-schema/main/schemas/test.json
2024-06-24T16:29:42.090Z [info] ---------------------------------------------
2024-06-24T16:29:42.090Z [info] ------------ ELIXIR biovalidator ------------
2024-06-24T16:29:42.091Z [info] ---------------------------------------------
2024-06-24T16:29:42.091Z [info] Started server on port 3020 with base URL /
2024-06-24T16:29:42.091Z [info] Server available at http://localhost:3020/
2024-06-24T16:29:42.091Z [info] PID file is available at /mnt/c/Users/mcasado/Documents/GitHub/biovalidator/src/server.pid
2024-06-24T16:29:42.092Z [info] Writing logs to: /mnt/c/Users/mcasado/Documents/GitHub/biovalidator/src/logs/
  1. Create a simple JSON document as follows. Notice how the referenced $id is the same as the one in the schema file.
{
    "data": {
        "test": "test"
    },
    "schema": {
        "$ref": "https://raw.githubusercontent.com/EbiEga/ega-metadata-schema/main/schemas/test.json"
    }
}
  1. Execute the validation request:
$ curl --data @test_doc.json -H "Content-Type: application/json" -X POST "http://localhost:3020/validate"
  1. Observe the logs from Biovalidator, displaying a warning about an empty schema $id and that it won't be cached.
2024-06-24T16:29:48.622Z [warn] Compiling schema with empty schema $id. Schema will not be cached.
2024-06-24T16:29:48.646Z [info] Returning referenced schema from cache: https://raw.githubusercontent.com/EbiEga/ega-metadata-schema/main/schemas/test.json
2024-06-24T16:29:48.649Z [info] New validation request: Processed successfully in 28ms.

Observed behaviour

Biovalidator complains about an empty schema $id. Error message sources from:

logger.warn("Compiling schema with empty schema $id. Schema will not be cached.");

Expected behaviour

The schema's $id should be identified without a warning. It is retrieved successfully from cache and used for validation, but the warning seems misleading.

Additional context

No response

@M-casado M-casado added the bug Something isn't working label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants