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

Error in JsonValidatorHandler when the remote registry can't be accessed #817

Closed
attilakreiner opened this issue Feb 28, 2024 · 2 comments · Fixed by #889
Closed

Error in JsonValidatorHandler when the remote registry can't be accessed #817

attilakreiner opened this issue Feb 28, 2024 · 2 comments · Fixed by #889
Assignees
Labels
bug Something isn't working

Comments

@attilakreiner
Copy link
Contributor

attilakreiner commented Feb 28, 2024

Describe the bug
When you set up zilla with validation and schema-registry enabled, but the schema registry is inaccessible zilla crashes with a NPE.

To Reproduce
Steps to reproduce the behavior:

  1. Start zilla with a configuration where json validation and schema-registry is enabled e.g.
---
name: test
telemetry:
  exporters:
    stdout0:
      type: stdout
catalogs:
  catalog0:
    type: schema-registry
    options:
      url: http://localhost:8081
      context: default
      max-age: 30
bindings:
  north_tcp_server:
    type: tcp
    kind: server
    options:
      host: 0.0.0.0
      port: 7114
    exit: north_http_server
  north_http_server:
    type: http
    kind: server
    options:
      requests:
        - path: /hello
          method: POST
          content:
            model: json
            catalog:
              catalog0:
                - subject: item
    exit: south_http_client
  south_http_client:
    type: http
    kind: client
    exit: south_tcp_client
  south_tcp_client:
    type: tcp
    kind: client
    options:
      host: localhost
      port: 8080

  1. Make sure the schema registry is not available at http://localhost:8081
  2. Run the command curl -v "localhost:7114/hello" -X POST -d "{'greeting':'hello'}"
  3. Zilla crashes at this line with a stack trace:
org.agrona.concurrent.AgentTerminationException: java.lang.NullPointerException: Cannot invoke "jakarta.json.spi.JsonProvider.createParser(java.io.InputStream)" because "provider" is null
	at io.aklivity.zilla.runtime.engine/io.aklivity.zilla.runtime.engine.internal.registry.EngineWorker.doWork(EngineWorker.java:761)
	at org.agrona.core/org.agrona.concurrent.AgentRunner.doDutyCycle(AgentRunner.java:291)
	at org.agrona.core/org.agrona.concurrent.AgentRunner.run(AgentRunner.java:164)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.NullPointerException: Cannot invoke "jakarta.json.spi.JsonProvider.createParser(java.io.InputStream)" because "provider" is null
	at io.aklivity.zilla.runtime.model.json/io.aklivity.zilla.runtime.model.json.internal.JsonValidatorHandler.validate(JsonValidatorHandler.java:78)
	at io.aklivity.zilla.runtime.engine/io.aklivity.zilla.runtime.engine.model.ValidatorHandler.validate(ValidatorHandler.java:41)
	at io.aklivity.zilla.runtime.binding.http/io.aklivity.zilla.runtime.binding.http.internal.stream.HttpServerFactory$HttpServer$HttpExchange.validateContent(HttpServerFactory.java:3231)
	at io.aklivity.zilla.runtime.binding.http/io.aklivity.zilla.runtime.binding.http.internal.stream.HttpServerFactory$HttpServer.onDecodeBody(HttpServerFactory.java:2300)
	at io.aklivity.zilla.runtime.binding.http/io.aklivity.zilla.runtime.binding.http.internal.stream.HttpServerFactory.decodeContent(HttpServerFactory.java:1425)

Expected behavior

  1. Zilla shouldn't crash.
  2. There is a decision to be made whether we deem inputs valid or invalid in the case the schema registry is not accessible. As discussed with @jfallows, we should follow the policy to deem inputs invalid if the schema registry is inaccessible.

Screenshots
N/A

Additional context

IMPORTANT NOTE: The repro steps above are pointing out the erratic behaviour in the case of json validation, but we should double check if the same problem exists in the case of avro and protobuf as well, and if so, those need to be fixed as well.

@attilakreiner attilakreiner added the bug Something isn't working label Feb 28, 2024
@attilakreiner
Copy link
Contributor Author

@jfallows @aDaemonThread FYI

@ankitk-me
Copy link
Contributor

Based on debugging, this crash is due to a missing null check in the model-json. This issue is not specific to schema registry being unreachable, we will hit this issue whenever schema is not found while validation.

We have already handled this in other models (avro, protobuf).

Fix: #889

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

Successfully merging a pull request may close this issue.

2 participants