fix: #224 - #272
fix: #224#272Flipped199 wants to merge 1 commit into
Conversation
… 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.
|
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. |
Summary
This PR fixes requests for methods without parameters when using a self-hosted Telegram Bot API server.
Previously,
rawRequestalways created a multipart request body, even whenparamswas nil. That behavior appears to break some self-hosted Bot API implementations for parameterless methods such asgetMe.What changed
paramsis nilio.Pipeandmultipart.Writerwhen parameters are actually presentisNilhelper instead of callingreflect.Value.IsNil()directly on unsupported kindsWhy
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
Related
Fixes #224