Skip to content

parameterConsistency field not deserializable from YAML #622

@benbellick

Description

@benbellick

YAML extension files containing parameterConsistency in variadic function definitions fail to load with the error:

Unrecognized field "parameterConsistency" (class ImmutableSimpleExtension$VariadicBehavior$Json),
not marked as ignorable (2 known properties: "min", "max"])

As a minimal test case to demonstrate the failure:

@Test
public void testParameterConsistencyLoading() {
  String yamlContent =
      "urn: extension:test:example\n"
          + "scalar_functions:\n"
          + "  - name: test_func\n"
          + "    impls:\n"
          + "      - args:\n"
          + "          - name: arg1\n"
          + "            value: string\n"
          + "        variadic:\n"
          + "          min: 1\n"
          + "          parameterConsistency: CONSISTENT\n"
          + "        return: string\n";

  SimpleExtension.ExtensionCollection collection =
      SimpleExtension.load("test://example", yamlContent);

  assertEquals(
      SimpleExtension.VariadicBehavior.ParameterConsistency.CONSISTENT,
      collection.scalarFunctions().get(0).variadic().get().parameterConsistency());
}

This can be fixed by adding the @Value.Default annotation to the VariadicBehavior.parameterConsistency() method. Without it, the Immutables library cannot recognize it as a deserializable field.

This will need one extra step, which is to actually thread the parameterConsistency info through to the function validation to ensure that the parameterConsistency is actually enforced.

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