Skip to content

rulec v0.22.0

Choose a tag to compare

@github-actions github-actions released this 01 Oct 12:30
· 5 commits to main since this release

Rules that passed and now fail

Code What it stops
E002 An alias in parentheses that is not a name. 六十(60) passed with the parentheses dropped, so the value had no alias at all.
E032 A rule that imports an enum from a .proto whose name has a run of capitals (HTTPMethod) or whose values leave a digit after the prefix (SIZE_60), with the aliases the old reading asked for — the zero value http_method_unspecified among them. The prefix is now split the way buf splits it (HTTP_METHOD_), and SIZE_60 is size_60. A contract that passes buf lint no longer fails E032 for its names.

Fixed

  • The Connect service of a rule with an enum imported from a .proto did not start as generated: it imported the contract's stubs as a top-level module, found only with stubs/ added to PYTHONPATH. It imports them from stubs/ now.
  • rulec test failed the Connect passes of such a rule, and buf generate in the generated proto/ stopped at the import: the contract was not in the module. See Changed.
  • rulec api and rulec doc --format html looked for the files a rule cites from the working directory instead of the rule's own. api named an imported enum without its package, and the approver's page read inputs out of a .proto contract in a way protojson does not write them.
  • A rule's own enum whose alias has a run of capitals (HTTPRoute) was written to the .proto as H_T_T_P_ROUTE_…, which buf lint refuses and on which the service failed to start. It is HTTP_ROUTE_….
  • The service's description said --http needs nothing installed. The server is the standard library's; connectrpc and the stubs are still needed.

Added

  • rulec api's connect entry describes the wire for a caller that writes the JSON by hand: enums, with each value's name on the wire and its number, the name of value 0 when it means "not set", and the contract an imported enum comes from; optional and enum on every field; and element_fields for a rule that walks a sequence.

Changed

  • The generated Connect service refuses a request that leaves an input out (invalid_argument, 会員: not set). Every field of the request is now optional in the .proto. proto3 read a field left out as its zero, so a request that named nothing was decided as 0, false and the first value — and, where a contract puts a real value at 0, as that value. A caller that leaves false or 0 out of its JSON is now refused, and buf breaking reports the change.
  • It refuses a field or an enum value the request message does not have (invalid_argument). Connect's JSON reader drops them by default, so a misspelt input was decided as zero.
  • gen copies the contract an import proto enum comes from into the generated module, byte for byte, at the path its package gives it (proto/shop/v1/order.proto), and the generated .proto imports it from there. A file the contract imports comes with it when it is found beside it; one from a BSR module, such as protovalidate's, does not, and buf names it. Two different contracts that would land on one path stop gen.

One static binary per platform, no runtime; on Linux also as a .deb and an .rpm. Verify a download against SHA256SUMS before running it; the install page says how.