Skip to content

[Bug] 1.11.0 RBI: Workflow.upsert_memo sigs fail srb tc (overload and keyword args are not valid Sorbet) #683

Closed

Description

@jacksonhuether

What are you really trying to do?

Upgrade temporalio 1.10.1 → 1.11.0 in a Rails app that type-checks with Sorbet. Gem RBIs come from tapioca, which merges the RBIs this gem ships in rbi/ (thanks for #412).

Describe the bug

In 1.11.0 (Event Groups, #589), rbi/temporalio/workflow.rbi declares Workflow.upsert_memo(hash = nil, event_groups: nil, **memo) with two overload.params(...) sigs plus one plain sig. Sorbet's static checker rejects that for two reasons:

  1. overload isn't a sig builder: Malformed `sig`: `overload` is invalid in this context. sorbet-runtime doesn't define it either.
  2. Several sigs on one method are an overload, and Sorbet doesn't allow overloads on a method with keyword arguments (https://srb.help/5003).

Tapioca drops the unknown overload marker when it merges the shipped RBI, so every project using tapioca-generated RBIs fails srb tc on 1.11.0 with 5 errors like:

sorbet/rbi/gems/[email protected]:120952: Malformed `sig`. Overloaded functions cannot have keyword arguments:  `event_groups` https://srb.help/5003

Suggested fix: keep only the existing third sig. It already covers both call forms:

sig do
  params(
    hash: T.nilable(T::Hash[T.any(Symbol, String), T.nilable(Object)]),
    event_groups: T.nilable(T::Array[Temporalio::Workflow::EventGroup]),
    memo: T.nilable(Object)
  ).void
end
def upsert_memo(hash = nil, event_groups: nil, **memo); end

The RBS can keep its | overload; only the Sorbet RBI can't express it. It might also be worth running srb tc over rbi/ in CI. test/rbi_parse_test.rb only checks that files parse with the rbi gem, which accepts overload.params, and the TEMPORAL_SORBET_RUNTIME_CHECK run wouldn't flag static-only errors.

How did you hit this issue?

A Dependabot bump to 1.11.0 failed our srb tc CI. Runtime and tests are fine; this is static type checking only. For now we drop the two overload sigs from the generated RBI after generation, and we'd like to remove that workaround.

Minimal Reproduction

srb tc --no-config repro (Sorbet 0.6.13672) on repro/repro.rbi:

# typed: true
module Repro
  class << self
    sig { overload.params(hash: T::Hash[String, T.nilable(Object)], event_groups: T.nilable(T::Array[Integer])).void }
    sig { overload.params(event_groups: T.nilable(T::Array[Integer]), memo: T.nilable(Object)).void }
    sig { params(hash: T.nilable(T::Hash[String, T.nilable(Object)]), event_groups: T.nilable(T::Array[Integer]), memo: T.nilable(Object)).void }
    def upsert_memo(hash = nil, event_groups: nil, **memo); end
  end
end
  • As shipped: 7 errors (2 for overload being invalid, 5 for keyword-arg overloads).
  • With overload. removed (what tapioca writes): 5 errors.
  • With only the third sig: No errors! Great job.

Environment/Versions

  • Linux x86_64; temporalio 1.11.0 (1.10.1 is fine); Sorbet and sorbet-runtime 0.6.13672; tapioca 0.20.0; rbi 0.4.3; Ruby 3.4.13; released gem (no Docker or source build)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions