Skip to content

polyline_tube_input (and siblings): empty metadata string throws instead of being treated as no-op #72

Description

@petlenz

Symptom

A schema-driven shape input config with "metadata": "" produces:

[json.exception.parse_error.101] parse error at line 1, column 1:
attempting to parse an empty input; check that your input string or
stream contains the expected JSON

…during shape construction, not during schema validation.

Root cause

include/rvegen/inputs/shape_input_base.h:90:

if (handler.contains("metadata")) {
  auto const& blob = handler.template get<std::string>("metadata");
  _info.json().merge_patch(nlohmann::json::parse(blob));
}

The field's description is "optional JSON-encoded string of key/value pairs merged into every produced shape's info blob". The schema marks it as not-required, but at runtime a present-but-empty value (legal per the schema) still hits the nlohmann::json::parse(blob) call, which throws.

The contains-check is the only present-vs-absent guard; an empty string slips past it.

Why it matters

Tessera's pipeline runner can't distinguish this from any other construction failure — it surfaces as a generic 'Pipeline failed' dialog with the json parse-error text, which is opaque to end users. The user's natural reflex (filling every field of the form, leaving metadata empty) is the failure mode.

Suggested fix

Make either condition treat the field as absent:

if (handler.contains("metadata")) {
  auto const& blob = handler.template get<std::string>("metadata");
  if (!blob.empty()) {
    _info.json().merge_patch(nlohmann::json::parse(blob));
  }
}

Alternative: catch nlohmann::json::parse_error and wrap with a more informative message naming the field (metadata: invalid JSON: <what>). The empty-check fix above is the more useful one — a present-but-empty field is 'I'm not using metadata', not 'I'm trying to set metadata to the empty JSON document'.

Scope

Applies to every input using shape_input_base::read_metadata: circle_input, rectangle_input, box_input, polyline_tube_input, and any future input that inherits the helper. One change in shape_input_base.h covers them all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions