apicurio-registry icon indicating copy to clipboard operation
apicurio-registry copied to clipboard

protobuf 3 forward compatibility

Open mathianasj opened this issue 2 years ago • 4 comments

If I enable forward compatibility and add a new field I would expect it to pass forward compatibility checks, but instead it fails, I can provide a reproducer if that is helpful

mathianasj avatar Jun 03 '22 14:06 mathianasj

Reproducers are always helpful! Thanks.

EricWittmann avatar Jun 03 '22 17:06 EricWittmann

before.proto

syntax = "proto3";

package com.example;

message Person {
    int32 id = 1;
    string firstName = 2;
    string lastName = 3;
}

after.proto

syntax = "proto3";

package com.example;

message Person {
    int32 id = 1;
    string firstName = 2;
    string lastName = 3;
    int32 addressId = 4;
}

UserPropsTest.java

import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.junit.jupiter.api.Test;

import io.apicurio.registry.protobuf.ProtobufDifference;
import io.apicurio.registry.rules.compatibility.protobuf.ProtobufCompatibilityCheckerLibrary;
import io.apicurio.registry.utils.protobuf.schema.ProtobufFile;

public class UserPropsTest {
    @Test
    public void testForward() throws IOException {
        ProtobufFile before = new ProtobufFile(new File(UserPropsTest.class.getResource("before.proto").getFile()));
        ProtobufFile after = new ProtobufFile(new File(UserPropsTest.class.getResource("after.proto").getFile()));

        ProtobufCompatibilityCheckerLibrary checker = new ProtobufCompatibilityCheckerLibrary(after, before);

        List<ProtobufDifference> entries = checker.findDifferences();
        System.out.println(entries);

        assertTrue(checker.validate());
    }
}

Expected to pass and show no differences, actual output failure with console

[ProtobufDifference(message=2 fields removed without reservation, message Person), ProtobufDifference(message=Field name changed, message Person , before: addressId , after null)]

mathianasj avatar Jun 06 '22 12:06 mathianasj

@EricWittmann see my reproducer and sample test with output

mathianasj avatar Jun 06 '22 12:06 mathianasj

Thanks @mathianasj .

EricWittmann avatar Jun 09 '22 18:06 EricWittmann