Skip to content

fix: advertise 100MB limit, files that exceed that limit show a message - #229

Merged
highesttt merged 2 commits into
mainfrom
highest/plat-38237
Aug 3, 2026
Merged

fix: advertise 100MB limit, files that exceed that limit show a message#229
highesttt merged 2 commits into
mainfrom
highest/plat-38237

Conversation

@highesttt

Copy link
Copy Markdown
Collaborator

No description provided.

@linear-code

linear-code Bot commented Aug 3, 2026

Copy link
Copy Markdown

PLAT-38237

@indent-zero

indent-zero Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor
PR Summary

Advertises a 100 MB per-file limit to Matrix clients via the bridge File capabilities and, on the receive path, replaces the failed Matrix upload for over-limit LINE media with a friendly MsgNotice across every supported media type. Follow-up commit generalized the guard to image/video/audio/file and added a metadata short-circuit so oversized payloads are never downloaded.

  • Adds handlers.BeeperMaxFileSize (100 MiB) and sets MaxSize on MsgImage, MsgFile, MsgVideo, MsgAudio, CapMsgVoice in LineClient.GetCapabilities.
  • Bumps GetBridgeInfoVersion capabilities 2 → 3 so clients re-fetch the updated caps.
  • New pkg/connector/handlers/media_size.go exposes oversizedMediaNoticeFromMetadata (early FILE_SIZE check with a 32-byte E2EE HMAC tolerance) and oversizedMediaNotice (post-download authoritative check), used by all Convert{File,Image,Video,Audio} handlers.
  • Adds unit tests for the notice generator, per-handler short-circuit behavior, and boundary/invalid FILE_SIZE fallback cases.
  • Updates reaction_test.go to expect the new 1/3 version pair.

Issues

All clear! No issues remaining. 🎉

3 issues already resolved
  • Notice body has an ungrammatical comma: "Open LINE, to view it." should be "Open LINE to view it." (fixed by commit c3ec1fa)
  • Oversize notice is only wired into ConvertFile, but MaxSize: 100MB is advertised for MsgImage, MsgVideo, MsgAudio, and CapMsgVoice too — LINE media of those types >100 MB still hits intent.UploadMedia and fails without a user-facing message. (fixed by commit c3ec1fa)
  • Oversize check runs after the full download and decrypt, wasting bandwidth/memory/CPU on files we then discard — data.ContentMetadata["FILE_SIZE"] (already populated on the send path) could short-circuit before hitting OBS. (fixed by commit c3ec1fa)

CI Checks

All CI checks passed on commit c3ec1fa.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: edfa6e1a-44cf-4b83-9900-f29e7f4c17a8

📥 Commits

Reviewing files that changed from the base of the PR and between c3d36ba and c3ec1fa.

📒 Files selected for processing (6)
  • pkg/connector/handlers/audio.go
  • pkg/connector/handlers/file.go
  • pkg/connector/handlers/image.go
  • pkg/connector/handlers/media_size.go
  • pkg/connector/handlers/media_size_test.go
  • pkg/connector/handlers/video.go
📜 Recent review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: Lint with 1.25
  • GitHub Check: build-docker
  • GitHub Check: Lint with 1.25
  • GitHub Check: build-docker
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Use go fmt for code formatting across all Go files
Use goimports with -local "github.com/highesttt/matrix-line-messenger" flag to group project-local imports correctly
Use zerolog for logging throughout the codebase
Do not use Msgf in logging; use Msg with structured fields instead
Use Stringer interface where applicable in Go code

Files:

  • pkg/connector/handlers/media_size_test.go
  • pkg/connector/handlers/image.go
  • pkg/connector/handlers/audio.go
  • pkg/connector/handlers/media_size.go
  • pkg/connector/handlers/file.go
  • pkg/connector/handlers/video.go
**/!(ltsm)/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/!(ltsm)/**/*.go: Run staticcheck on all Go files excluding pkg/ltsm package (transpiled WASM code)
Run go vet on all Go files excluding pkg/ltsm package (transpiled WASM code)

Files:

  • pkg/connector/handlers/media_size_test.go
  • pkg/connector/handlers/image.go
  • pkg/connector/handlers/audio.go
  • pkg/connector/handlers/media_size.go
  • pkg/connector/handlers/file.go
  • pkg/connector/handlers/video.go
🔇 Additional comments (7)
pkg/connector/handlers/media_size.go (2)

11-48: LGTM!


3-9: 📐 Maintainability & Code Quality

Resolve the unavailable checks before approval. gofmt passes. goimports and staticcheck are unavailable. go vet fails in maunium.net/go/mautrix because sqlite3.Error and sqlite3.ErrCorrupt are undefined.

pkg/connector/handlers/audio.go (1)

18-21: LGTM!

Also applies to: 102-105

pkg/connector/handlers/file.go (1)

17-20: LGTM!

Also applies to: 96-99

pkg/connector/handlers/image.go (1)

18-21: LGTM!

Also applies to: 102-105

pkg/connector/handlers/video.go (1)

19-22: LGTM!

Also applies to: 116-119

pkg/connector/handlers/media_size_test.go (1)

1-108: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added support for reporting file-size capabilities for image, file, video, audio, and voice messages.
    • Added a 100 MiB maximum media size limit.
  • Bug Fixes

    • Oversized media is now detected before or after download, preventing unnecessary processing and uploads.
    • Users receive a notice when media exceeds the allowed size.

Walkthrough

The connector adds a shared 100 MiB media limit. Handlers reject oversized media before download or upload, capabilities advertise the limit, and the capability version increases to 3.

Changes

File-size capability and enforcement

Layer / File(s) Summary
Oversized file notice flow
pkg/connector/handlers/media_size.go, pkg/connector/handlers/*, pkg/connector/handlers/media_size_test.go
Media handlers validate metadata before download and downloaded or decrypted size before Matrix upload. Oversized media returns a Matrix notice. Tests cover limits, metadata parsing, encrypted overhead, and short-circuiting.
Capability advertisement and version
pkg/connector/userinfo.go, pkg/connector/connector.go, pkg/connector/*_test.go
Supported media capabilities advertise the shared 100 MiB limit. The capability version and related tests now use version 3.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant LineMetadata
  participant MediaHandler
  participant Matrix
  LineMetadata->>MediaHandler: FILE_SIZE metadata
  MediaHandler->>MediaHandler: compare with BeeperMaxFileSize
  MediaHandler->>LineMetadata: download and decrypt allowed media
  MediaHandler->>MediaHandler: check downloaded size
  MediaHandler->>Matrix: upload media or send oversized-media notice
Loading

Possibly related PRs

  • beeper/line#213: Both PRs modify GetBridgeInfoVersion and its capability-version test.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided, so its relevance to the changeset cannot be assessed. Add a concise description that explains the advertised 100 MB limit and the handling of oversized media.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the 100 MB limit announcement and oversized-file handling implemented by the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch highest/plat-38237

Comment @coderabbitai help to get the list of available commands.

Comment thread pkg/connector/handlers/file.go Outdated
Comment thread pkg/connector/handlers/file.go Outdated
@highesttt
highesttt merged commit 0fc10ea into main Aug 3, 2026
10 checks passed
@highesttt
highesttt deleted the highest/plat-38237 branch August 3, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant