8000 A `serving` slot named `session` is "Undefined method" in the served application, though its spec passes · Issue #451 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

A serving slot named session is "Undefined method" in the served application, though its spec passes #451

Open

Description

@akoskovacs
module DB.Store

serving Store do
  foul slot session(tokenDigest: String) -> Reply<Result<(String, Integer)?, String>> do
    return { reply: DB.Repositories.Sessions.find(@connection, tokenDigest) }
  end
end

sessionOf : Server<Store> -> String -> Result<(String, Integer)?, String>
foul sessionOf(store, tokenDigest) = flat(store.session(tokenDigest))

A spec that starts the store and calls sessionOf passes. In the application (tey run, which also links Rodolfo and Net.HTTP) the same call kills the server process:

** Generic server <0.84.0> terminating
** Last message in was {session,<<"12b00f75…">>}
** {<<"runtime error: Undefined method: session for DB.Store.Store">>,
    [{kex_io,undefined_method,3,…},
     {kex_intrinsic_process,handle_call,3,…},

Renaming the slot to holder fixed it; nothing else changed.

Looks related to #377 (slots not exported when the block sits in an imported module and Net.HTTP is in the program), which is closed. The other dozen slots in the same block are fine, so the name seems to matter.

Not yet minimized.

Environment: Kex 0.4.0-rc.1 (30c7979), Tey 0.2.1, Erlang/OTP 29.0.5 (Homebrew), macOS arm64. Found while building an application on Rodolfo 0.2 and Harmat 0.1.

Activity

  1. akoskovacs commented on Oct 10, 2026

    @akoskovacs
    CollaboratorAuthor

    A second instance, with a method on a record rather than a slot, and now with a single-spec reproduction of the "passes alone, fails when the HTTP stack is linked" part.

    module DB.Repositories.Holdings
    
    record HoldingRepository do
      relation : Relation
      owner : String
    end
    
    make HoldingRepository do
      foul remove(id: String) -> Result<Bool, String> do
        return @relation.deleted(id)
      end
    end
    

    DB.Repositories.Holdings.of(database, "x").remove("nope"):

    • in a spec that uses only the repositories: works;
    • in the served application, and in a spec that merely also evaluates Config.Routes.routes(store, hub) (a module with using Rodolfo):
    runtime error: Undefined method: remove for DB.Repositories.Holdings.HoldingRepository
    

    Renaming the method to discard fixes it. The record's other methods (all, fetch, save, create, adopt) are unaffected, as were the store's other slots when session failed. No other record in the program defined a remove at the time, so this is not two user types colliding; it looks like a name that Rodolfo or Net.HTTP brings into the program taking over the dispatch for every receiver.

    Type checking passes in both cases, so the only way to find these is to exercise each method in a program linked the way the application is.

  2. akoskovacs commented on Oct 17, 2026

    @akoskovacs
    CollaboratorAuthor

    Does not reproduce on current main (0fd796c), on either backend. The program links Net.HTTP and uses its Headers.remove. In it, a record's foul remove(id: String) -> Result<Bool, String> dispatches to the record's own function, and a serving slot named session called through a free sessionOf(store, tokenDigest) answers. The original program also links Rodolfo and was never minimised, so I'm leaving this open until it is checked in the application.

  3. akoskovacs commented on Oct 24, 2026

    @akoskovacs
    CollaboratorAuthor

    Confirmed and minimized on main (fc2586f), BEAM. A module DB.Store with a serving Store block that has two identical slots, session and holder, plus sessionOf(store, t) = store.session(t) and holderOf(store, t) = store.holder(t). Calling both from main:

    • with no other import, or with using Net.HTTP: both answer.
    • with using Net.HTTP.WebSocket in main: holderOf answers, and sessionOf fails with runtime error: Undefined method: session for Server.

    So it is the name session colliding with something Net.HTTP.WebSocket brings in.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BEAMBugSomething isn't workingConfirmed IssueBug is reproduced on the current development versionNeeds CheckingNeeds additional checks to confirmProcesses

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0