Skip to content

fix: #224 - #272

Closed
Flipped199 wants to merge 1 commit into
go-telegram:mainfrom
Flipped199:main
Closed

Flipped199 wants to merge 1 commit into
go-telegram:mainfrom
Flipped199:main

Conversation

@Flipped199

Copy link
Copy Markdown

Summary

This PR fixes requests for methods without parameters when using a self-hosted Telegram Bot API server.

Previously, rawRequest always created a multipart request body, even when params was nil. That behavior appears to break some self-hosted Bot API implementations for parameterless methods such as getMe.

What changed

  • Send a POST request with a nil body when params is nil
  • Only create io.Pipe and multipart.Writer when parameters are actually present
  • Add a safe isNil helper instead of calling reflect.Value.IsNil() directly on unsupported kinds

Why

This makes parameterless requests behave more like true empty-body HTTP requests instead of empty multipart form uploads.

It also avoids reflection panics for non-nilable value types.

Impact

  • Fixes compatibility with self-hosted/custom Telegram Bot API servers
  • Keeps existing multipart behavior for requests that actually contain parameters
  • Improves safety of nil checks in request building

Related

Fixes #224

TGlimmer added a commit to TGlimmer/gobot that referenced this pull request Jul 15, 2026
… 9.6/10.0

Adopt upstream implementations for Bot API 9.6/10.0 (merged upstream via
PR go-telegram#281) and new 10.1 rich message support (go-telegram#283), while keeping
fork-local changes:

- module path github.com/TGlimmer/gobot
- bodyless POST for parameterless methods (issue go-telegram#224 / PR go-telegram#272)
- Bot.IDOrErr for malformed-token diagnostics (issue go-telegram#277)
- ChatPermissions *bool fields for explicit-false serialization (issue go-telegram#271)

Remove local models superseded by upstream equivalents (guest.go,
live_photo.go, poll_media.go) and dedupe auto-merge artifacts in
Message struct and build_request_form_test.go.
@negasus

negasus commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Thank you for working on this fix. The parameterless-request problem in #224 was addressed in 62994f8 and released in v1.27.0, so this PR has been superseded.

The released implementation sends no body or multipart Content-Type for both nil parameters (including typed nil pointers) and parameter structs whose fields are all omitted. It also builds non-empty request bodies into a buffer with a known Content-Length and GetBody, allowing HTTP/2 to replay a request after GOAWAY.

I compared this PR's head with v1.27.0 using the same request tests. Both handle nil and typed-nil parameters correctly; v1.27.0 also passes the empty-struct and populated-request replayability cases, while the pipe-based implementation in this PR does not.

The separate isNil helper is not needed for the supported method parameters: the methods pass struct pointers or nil, and those cases are already handled. A general isNilValue helper also already exists for attachment handling.

Closing this PR because the original issue is fixed in v1.27.0. Thank you for the contribution.

@negasus negasus closed this Oct 3, 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.

not supported self hosted telegram API

3 participants