davsclaus opened a new pull request, #30590: URL: https://github.com/apache/camel/pull/30590
JIRA: [CAMEL-27377](https://issues.apache.org/jira/browse/CAMEL-27377) (follow-up of CAMEL-27329, #30550) ## What was wrong When the `schema` option of the protobuf data format was given a `.proto` that imports another file, such as `import "shop/common.proto";`, it failed with the message of Wire's `CoreLoader`: ``` IllegalArgumentException: Cannot read the protobuf schema: unexpected load: shop/common.proto ``` `WireProtobufSchemaParser.build` already had a clear message for an unknown import, but it never ran: the linker calls the loader first, and the loader passed the path to Wire's `CoreLoader`, which throws `IllegalStateException` for any file it does not ship. ## The fix The parser's `Loader` now turns a failed load into an `IllegalArgumentException` that names the import and lists what can be imported: ``` Cannot read the protobuf schema: it imports shop/common.proto, but only the well-known types of google/protobuf can be imported (any.proto, descriptor.proto, duration.proto, empty.proto, struct.proto, timestamp.proto and wrappers.proto): put the types of shop/common.proto in the schema itself ``` The same message covers a `google/protobuf` file that Wire does not ship (such as `type.proto`), and the old message in `build` now uses it too. The original Wire exception is kept as the cause. The component doc says what happens with other imports (catalog copy updated). Side note, not changed here: `wellKnownType` has a `google/protobuf/field_mask.proto` case, but Wire's `CoreLoader` does not ship `field_mask.proto`, so that case is never reached. Importing it now gives the message above, as `type.proto` does. The doc already leaves `field_mask.proto` out of the supported list. ## Tests - `ProtobufSchemaDynamicMessageTest`, new tests: - `importOfAnotherFileSaysOnlyTheWellKnownTypesCanBeImported`: `import "shop/common.proto"` gives the exact message. **It failed before the fix** with `unexpected load: shop/common.proto`. - `importOfAnUnsupportedGoogleFileSaysOnlyTheWellKnownTypesCanBeImported`: `google/protobuf/type.proto`. It also failed before the fix. - `wellKnownTypesCanBeImported`: timestamp, duration and wrappers still link. - `mvn -o test` in camel-protobuf-schema: 10 tests, 0 failures. _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
