Skip to content

fix(compiler): validate rpc request/response types#3485

Open
retryoos wants to merge 3 commits intoapache:mainfrom
retryoos:feat-rpc-type-validation
Open

fix(compiler): validate rpc request/response types#3485
retryoos wants to merge 3 commits intoapache:mainfrom
retryoos:feat-rpc-type-validation

Conversation

@retryoos
Copy link

Summary

  • Add schema validation for service RPC request/response types in the compiler IR validator.
  • Extend FDL/Proto/FBS service tests so RPCs with unknown request/response types now fail validation.
  • Document service RPC type validation in the compiler guide and add a small service.fdl example plus a foryc usage snippet.

Technical details

  • SchemaValidator._check_type_references now also walks schema.services and verifies that each RpcMethod.request_type and RpcMethod.response_type resolves via schema.get_type(...). If a type is missing, it reports Unknown type 'X' at the RPC location.
  • New tests:
    • test_service_unknown_request_type_fails_validation,
      test_service_unknown_response_type_fails_validation,
      test_service_known_types_pass_validation in test_fdl_service.py (one test also asserts that the error carries a non-null location).
    • Matching unknown-type validation tests in test_proto_service.py and test_fbs_service.py to cover the Proto and FlatBuffers frontends feeding into the shared IR.
  • Docs:
    • docs/compiler/compiler-guide.md now mentions that RPC request/response types are validated like other type references, and includes a foryc compiler/examples/service.fdl --java_out=... --python_out=... example.
  • Example:
    • compiler/examples/service.fdl defines HelloRequest, HelloReply, and a Greeter service with a unary SayHello RPC.

Testing

Locally on macOS:

cd compiler

python -m pytest fory_compiler/tests/test_fdl_service.py -v
python -m pytest fory_compiler/tests/test_proto_service.py -v
python -m pytest fory_compiler/tests/test_fbs_service.py -v
python -m pytest fory_compiler/tests/ -v

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant