Skip to content

Duplicate entries silently ignored in entites JSON deserialization #357

Description

@john-h-kastner-aws
  • Duplicate attributes
    #[test]
    fn json_duplicate_attributes_error() {
        let json = r#"[
            {
                "uid": { "type": "foo", "id": "bar" },
                "attrs": {
                    "bacon": "eggs",
                    "bacon": "beans"
                },
                "parents": []
            }
        ]"#;
        assert_deserialization_err(json, "");
    }

    fn assert_deserialization_err(json: &str, err: &str) {
        let eparser: EntityJsonParser<'_> =
            EntityJsonParser::new(None, Extensions::all_available(), TCComputation::ComputeNow);
        assert_matches!(eparser.from_json_str(json), Err(EntitiesError::Deserialization(actual_err)) => {
                assert!(actual_err.to_string().contains(err), "Expected an error containing `{}`, but saw `{}`", err, actual_err);
        });
    }
    #[test]
    fn json_duplicate_uid_error() {
        let json = r#"[
            { "uid": { "type": "foo", "id": "bar" }, "attrs": {}, "parents": [] },
            { "uid": { "type": "foo", "id": "bar" }, "attrs": {}, "parents": [] }
        ]"#;
        assert_deserialization_err(json, "");
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. This is as high priority issue.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions