Skip to content

fix(python): indent the flattened setup in endpoint-less clients - #303

Closed
moetemp wants to merge 8 commits into
moe/up/ts-long-resource-paramsfrom
moe/up/flattened-setup-indent
Closed

moetemp wants to merge 8 commits into
moe/up/ts-long-resource-paramsfrom
moe/up/flattened-setup-indent

Conversation

@moetemp

@moetemp moetemp commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What changed?

This PR renders the setup of a @nexus.flatten-in-api record at the method body indent, in the Python <Service>Client of a service with no @nexus.endpoint.

The first commit gives user-service an update-profile operation with two flattened records, with today's output. One record has a required field, and the other has only optional fields. Python has no output in that commit, since its services.py doesn't parse. The second commit is the fix.

It's based on #296.

Why?

The setup took the indent of a module function, so its lines weren't inside the method body and services.py didn't parse.

How did you test it?

Link to a test plan if any -

  • Unit Tests
  • Staging
  • End to End Tests

test_user_service.py calls update_profile from a Workflow on a real Nexus endpoint, with the optional record set and unset, and checks each request.

@moetemp
moetemp requested a review from a team as a code owner October 27, 2026 04:37
@moetemp
moetemp marked this pull request as draft October 27, 2026 07:48
@moetemp
moetemp force-pushed the moe/up/flattened-setup-indent branch from d083e2e to 026f1d0 Compare October 28, 2026 16:37
This was referenced Oct 28, 2026
@moetemp
moetemp changed the base branch from main to moe/up/ts-long-resource-params October 28, 2026 22:57
@moetemp
moetemp force-pushed the moe/up/ts-long-resource-params branch from 9e1d318 to 566af30 Compare October 29, 2026 04:00
@moetemp
moetemp force-pushed the moe/up/flattened-setup-indent branch 2 times, most recently from 2b18cce to bca32e1 Compare October 29, 2026 06:28
@moetemp
moetemp force-pushed the moe/up/ts-long-resource-params branch 2 times, most recently from 8c475f3 to a649a98 Compare October 29, 2026 07:00
@moetemp
moetemp force-pushed the moe/up/flattened-setup-indent branch from bca32e1 to 1967f3a Compare October 29, 2026 07:00
The sample takes Brook's WIT, on the Stream protos of temporalio/api#895 at 482ec010. No SDK has
those protos, so the sample projects hold their bindings. Only .NET generates the service, since
Python and TypeScript panic on the read item's oneof.
Python and TypeScript panic on it, so their outputs keep their previous content. .NET types each
case as the raw proto message, not as its record.
Variant planning kept such a case as the raw proto message. Python and TypeScript then panicked
on a message conversion that wasn't model-shaped, and .NET typed the case as the proto class.
The case plans as the record, as a record field does. A .NET case record names its payload's
model in full, since it hides a model of its own name. Brook's stream service generates for
TypeScript, and its .NET read item holds the records.
nexgen maps every temporal/... proto to a temporalio module. The Stream protos aren't in
temporalio yet, so the service's imports don't resolve, and basedpyright skips it.
nexgen ships `proto/nexus/options.proto`, whose `nexus.python_module` file option names the
Python module of a file's messages and enums. nexgen reads it from the raw descriptor bytes,
since prost drops extension fields. The stream sample's protos set it, so Python imports them
from the sample's streamprotos package, and basedpyright checks the stream service.
A proto-backed request holds a 64-bit integer as a `Long`, but a resource method took a number. A
Brook offset doesn't fit in a number. A resource field or method param that a proto message of
the request reads is a `Long`, so it goes into the request as it is. A 64-bit map key there is a
string, as in the request model. Brook's stream service type-checks.
Python's client of a service with no endpoint sets up a flattened record at the module indent, so
its services.py doesn't parse and the Python output keeps its previous content.
The setup of a @nexus.flatten-in-api record always took the indent of a module function. In a
method of the client of a service with no endpoint, the code then left the method body, and
services.py didn't parse. The user-service client generates its update_profile method.
@moetemp
moetemp force-pushed the moe/up/flattened-setup-indent branch from 1967f3a to cf1a028 Compare October 29, 2026 07:35
@moetemp
moetemp force-pushed the moe/up/ts-long-resource-params branch 2 times, most recently from cbdf5c3 to 770e53a Compare October 29, 2026 09:29
@moetemp

moetemp commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Closing this. moetemp#85 takes the fix, where the stream sample needs it.

@moetemp moetemp closed this Oct 29, 2026
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