HostService.Send: the server's side of a file sent to the room #77

Closed
mikluko wants to merge 3 commits from server-send into main
Owner

Server side of HostService.Send (proto: #74).

  • Host.Send checks the session by its token, then the bounds, calls server.Files.SendFile, and records a File event (no bytes). Chat refusals map: ErrFileTooLarge/ErrFileKind to InvalidArgument, ErrNoRoom to FailedPrecondition, ErrChatDown to Unavailable.
  • LimitSend on the network listener: 401 before the body is read without a live session's token, 413 / MaxBytesReader past the largest file.
  • serve.Options.Files stays unset until ee's Attach is adapted to server.Files; Send answers Unavailable meanwhile.
  • A file that was sent but whose record failed to write is still reported as sent (logged).
Server side of `HostService.Send` (proto: #74). - `Host.Send` checks the session by its token, then the bounds, calls `server.Files.SendFile`, and records a `File` event (no bytes). Chat refusals map: `ErrFileTooLarge`/`ErrFileKind` to InvalidArgument, `ErrNoRoom` to FailedPrecondition, `ErrChatDown` to Unavailable. - `LimitSend` on the network listener: 401 before the body is read without a live session's token, 413 / `MaxBytesReader` past the largest file. - `serve.Options.Files` stays unset until ee's `Attach` is adapted to `server.Files`; Send answers Unavailable meanwhile. - A file that was sent but whose record failed to write is still reported as sent (logged).
HostService.Send: the server's side of a file sent to the room
Some checks failed
image / image (pull_request) Successful in 17s
test / changelog (pull_request) Failing after 4s
test / go (pull_request) Successful in 38s
b8b1549512
The handler checks the bounds itself (the host is not trusted with them),
hands the file to server.Files, and maps the chat side's refusals to codes
the agent reads. A sent file is recorded in the session's stream as a File
event, without its bytes.

The network listener refuses a Send without a live session's token before
reading its body: the call's own check comes after the body is read, so
without it any pod of the namespace could make the server read as much as
it was sent. serve.Options.Files is unset until the chat side's Attach is
adapted to server.Files.

Assisted-By: Claude <noreply@anthropic.com>
Author
Owner

Read at b8b1549. The handler, the bounds before the body and the refusals' codes are as described; a caller without a live session's token is turned away before the body is read, and the limit is right for both encodings. Three things before it merges.

  1. A file sent breaks the session's transcript. appendEvent and eventsAfter know the new kind, scanEntry in internal/session/transcript.go does not: for a start that holds a File event Transcript returns "event N is of kind 4, which this server does not know", and the page answers that the transcript could not be read, for the whole start. The ticket has the transcript record that a file was sent. So scanEntry returns the File, the page shows it (name, kind, size, the room's event) and the raw stream has its line, with a test that a start with a File in it reads.

  2. A new kind of event is a change of what the database holds, and a server of an earlier version meets it without warning: the version check passes and its transcripts fail as in 1. The schema's version is the guard for exactly this, so the kind comes with a step of its own in migrate that changes nothing but the version, on top of #75's step to 3 (base this on #75's branch; they both move schemaVersion). If you would rather keep one step, say so and the kind goes into #75's and out with #68's release; the coordinator has that release alone, so I expect a step to 4.

  3. The CHANGELOG's entry says HostService.Send is served and the file goes to the session's room. In this tree nothing sets serve.Options.Files, so the call answers Unavailable, as the description says. Leave the entry to the pull request that wires the chat side, as #74 and #76 did.

One thing for the seam with roomcity-ee, not for this pull request: the file's kind reaches the chat side as the host says it (media_type), and the comment on Send says the host is not trusted with the bounds. Whichever side decides whether the room takes a kind has to look at the bytes, or an agent sends an SVG or an HTML page as image/png.

Read at b8b1549. The handler, the bounds before the body and the refusals' codes are as described; a caller without a live session's token is turned away before the body is read, and the limit is right for both encodings. Three things before it merges. 1. A file sent breaks the session's transcript. `appendEvent` and `eventsAfter` know the new kind, `scanEntry` in internal/session/transcript.go does not: for a start that holds a File event `Transcript` returns "event N is of kind 4, which this server does not know", and the page answers that the transcript could not be read, for the whole start. The ticket has the transcript record that a file was sent. So `scanEntry` returns the File, the page shows it (name, kind, size, the room's event) and the raw stream has its line, with a test that a start with a File in it reads. 2. A new kind of event is a change of what the database holds, and a server of an earlier version meets it without warning: the version check passes and its transcripts fail as in 1. The schema's version is the guard for exactly this, so the kind comes with a step of its own in `migrate` that changes nothing but the version, on top of #75's step to 3 (base this on #75's branch; they both move `schemaVersion`). If you would rather keep one step, say so and the kind goes into #75's and out with #68's release; the coordinator has that release alone, so I expect a step to 4. 3. The CHANGELOG's entry says `HostService.Send` is served and the file goes to the session's room. In this tree nothing sets `serve.Options.Files`, so the call answers Unavailable, as the description says. Leave the entry to the pull request that wires the chat side, as #74 and #76 did. One thing for the seam with roomcity-ee, not for this pull request: the file's kind reaches the chat side as the host says it (`media_type`), and the comment on Send says the host is not trusted with the bounds. Whichever side decides whether the room takes a kind has to look at the bytes, or an agent sends an SVG or an HTML page as `image/png`.
mikluko force-pushed server-send from b8b1549512
Some checks failed
image / image (pull_request) Successful in 17s
test / changelog (pull_request) Failing after 4s
test / go (pull_request) Successful in 38s
to a9da7f8dfd
All checks were successful
image / image (pull_request) Successful in 6s
test / go (pull_request) Successful in 44s
test / changelog (pull_request) Successful in 5s
2026-11-16 09:46:22 +00:00
Compare
mikluko closed this pull request 2026-11-16 09:46:32 +00:00
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mikluko/roomcity!77
No description provided.