risingwavelabs/risingwave · error · Error

schema from {url} not valid JSON

Error message

schema from {url} not valid JSON

What it means

Error::SchemaNotJson wraps a std::io::Error and reports that the document fetched from {url} is not valid JSON. Despite the io::Error source type, the message indicates the response body could not be parsed as JSON during read-to-string/parse handling.

Source

Thrown at src/connector/codec/src/decoder/json/mod.rs:61

use serde_json::Value;
use thiserror::Error;
use url::Url;

use super::avro::{MapHandling, avro_schema_to_fields};

#[derive(Debug, Error, thiserror_ext::ContextInto)]
pub enum Error {
    #[error("could not open schema from {filename}")]
    SchemaFromFile {
        filename: String,
        source: std::io::Error,
    },
    #[error("parse error for url {url}")]
    UrlParse {
        url: String,
        source: url::ParseError,
    },
    #[error("schema from {url} not valid JSON")]
    SchemaNotJson { url: String, source: std::io::Error },
    #[error("request error")]
    Request { url: String, source: reqwest::Error },
    #[error("schema from {url} not valid JSON")]
    SchemaNotJsonSerde {
        url: String,
        source: serde_json::Error,
    },
    #[error(
        "ref `{ref_string}` cannot be resolved as a pointer, and `{ref_fragment}` cannot be found in the schema"
    )]
    JsonRefPointerNotFound {
        ref_string: String,
        ref_fragment: String,
    },
    #[error("json ref error")]
    JsonRef {
        #[from]

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Open the URL in a browser or curl it and confirm the body is valid JSON.
  2. Point the schema location at the correct registry subject/version endpoint.
  3. Check for proxy/firewall interception returning HTML instead of the schema.

Example fix

// before
schema.location = 'http://registry:8081/schemas/ids/1'  // returns HTML error page
// after
schema.location = 'http://registry:8081/subjects/my-topic-value/versions/1/schema'
Defensive patterns

Strategy: validation

Validate before calling

const body = await fetch(url).then(r => r.text());
JSON.parse(body); // throws early if the endpoint returns non-JSON

Try / catch

match result {
  Err(Error::SchemaNotJson { url, .. }) => log::error!("non-JSON body from {url}; check the endpoint"),
  other => other?,
}

Prevention

When it happens

Trigger: Fetching a JSON schema from a file or URL whose body is HTML (error page), plain text, empty, or otherwise not JSON, and reading/parsing it via IO-based code paths.

Common situations: Schema registry URL returning an HTML 404/error page; pointing at a YAML or Avro (IDL) schema file; proxy captive portal responses; wrong registry endpoint.

Understand the failure class

Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/bdd9f9077635ca44. Report an issue: GitHub.