fix: send empty JSON body in session.create()#44
Open
illera88 wants to merge 1 commit intoanomalyco:mainfrom
Open
fix: send empty JSON body in session.create()#44illera88 wants to merge 1 commit intoanomalyco:mainfrom
illera88 wants to merge 1 commit intoanomalyco:mainfrom
Conversation
The OpenCode server's POST /session endpoint requires a JSON request
body (Content-Type: application/json), even when no parameters are
provided. Without a body, the server returns 400 'Malformed JSON in
request body'.
Both the sync and async create() methods now send body={} so that the
SDK serializes an empty JSON object, matching what the server expects.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
session.create()(both sync and async) now sendsbody={}so that the HTTP request includesContent-Type: application/jsonwith an empty JSON object.Problem
The OpenCode server's
POST /sessionendpoint requires a JSON request body. Whencreate()is called without any parameters, the SDK sends a POST with no body, causing the server to respond with400 Malformed JSON in request body.Reproduction
Current workaround
Fix
Added
body={}to theself._post()calls in bothSessionResource.create()andAsyncSessionResource.create(). This ensures the SDK always sends a valid empty JSON object when no session parameters (liketitleorparentID) are provided.