René's URL Explorer Experiment


Title: Assistant messages with empty content are sent as `"content": null`, causing a non-retryable 400 · Issue #10 · dev2k6/command-code-proxy-server · GitHub

Open Graph Title: Assistant messages with empty content are sent as `"content": null`, causing a non-retryable 400 · Issue #10 · dev2k6/command-code-proxy-server

X Title: Assistant messages with empty content are sent as `"content": null`, causing a non-retryable 400 · Issue #10 · dev2k6/command-code-proxy-server

Description: Problem ConvertMessages forwards assistant messages that have no text and no tool call as "content": null, which the upstream gateway rejects with a non-retryable 400. The whole request fails. Real-world trigger: a client sends role: "as...

Open Graph Description: Problem ConvertMessages forwards assistant messages that have no text and no tool call as "content": null, which the upstream gateway rejects with a non-retryable 400. The whole request fails. Real...

X Description: Problem ConvertMessages forwards assistant messages that have no text and no tool call as "content": null, which the upstream gateway rejects with a non-retryable 400. The whole request f...

Opengraph URL: https://github.com/dev2k6/command-code-proxy-server/issues/10

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Assistant messages with empty content are sent as `\"content\": null`, causing a non-retryable 400","articleBody":"## Problem\n\n`ConvertMessages` forwards assistant messages that have no text and no tool call as `\"content\": null`, which the upstream gateway rejects with a **non-retryable 400**. The whole request fails.\n\nReal-world trigger: a client sends `role: \"assistant\"` with empty content in the message history. This is common in practice — for example, a turn cancelled mid-stream leaves a partial assistant message behind (reasoning only, no text), and many OpenAI-compatible clients emit `content: null` on tool-call-only assistant turns.\n\n## Reproduction\n\nMinimal request against the proxy (no special setup needed):\n\n```bash\ncurl -X POST http://127.0.0.1:55990/v1/chat/completions \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer $COMMANDCODE_API_KEY\" \\\n  -d '{\n    \"model\": \"deepseek/deepseek-v4-flash\",\n    \"max_tokens\": 16,\n    \"stream\": false,\n    \"messages\": [\n      {\"role\": \"user\", \"content\": \"hi\"},\n      {\"role\": \"assistant\", \"content\": \"\"},\n      {\"role\": \"user\", \"content\": \"say ok\"}\n    ]\n  }'\n```\n\nResponse:\n\n```json\n{\"error\":{\"message\":\"Upstream error: {\\\"success\\\":false,\\\"error\\\":{\\\"code\\\":\\\"BAD_REQUEST\\\",\\\"status\\\":400,\\\"message\\\":\\\"Invalid request error. ... Validation error: Invalid input: expected string, received null at \\\\\\\"params.messages[1].content\\\\\\\" or Invalid input: expected array, received null at \\\\\\\"params.messages[1].content\\\\\\\" or Invalid input: expected \\\\\\\"tool\\\\\\\" at \\\\\\\"params.messages[1].role\\\\\\\"; Invalid input: expected array, received null at \\\\\\\"params.messages[1].content\\\\\\\"\\\",\\\"docs\\\":\\\"https://commandcode.ai/docs/reference/errors/bad_request\\\"}}\",\"type\":\"api_error\"}}\n```\n\nNote the position in the error (`params.messages[1]`) points straight at the empty assistant message.\n\n### Trigger matrix\n\nEvery form below produces the same 400 on the current `main`:\n\n| message content | result |\n| --- | --- |\n| `\"content\": \"\"` | 400 |\n| `\"content\": null` | 400 |\n| `content` omitted entirely | 400 |\n| `\"content\": []` | 400 |\n| `\"content\": [{\"type\":\"text\",\"text\":\"\"}]` | 400 |\n| `\"content\": \"hello\"` (control) | 200 |\n\n## Root cause\n\nTwo lines combine to produce invalid JSON:\n\n1. `parseContent` returns a **nil** slice for empty content — `internal/proxy/convert.go:209-212` (and the same shape for `nil` input at `:207`):\n\n```go\ncase string:\n    if v == \"\" {\n        return nil\n    }\n```\n\n2. `CCMessage.Content` has **no `omitempty`**, so a nil slice marshals as `null` — `internal/api/commandcode.go:23-26`:\n\n```go\ntype CCMessage struct {\n    Role    string          `json:\"role\"`\n    Content []CCContentPart `json:\"content\"`\n}\n```\n\nThen `ConvertMessages` appends that message unconditionally (`internal/proxy/convert.go:75`):\n\n```go\nccMsgs = append(ccMsgs, api.CCMessage{Role: m.Role, Content: parseContent(m.Content, toolNames)})\n```\n\nSo an assistant message with empty content goes upstream as `{\"role\":\"assistant\",\"content\":null}`. The upstream schema accepts `string | array` for `content`, never `null` — hence the 400, which the client treats as non-retryable and the turn dies permanently. Every subsequent request on that conversation re-sends the same poisoned message and fails identically, so the session is stuck.\n\n## Suggested fix\n\nSkip messages that convert to no content parts, rather than sending them. Such a message carries no information for the model, and dropping it keeps tool-call/tool-result pairing intact (a message with neither text nor a tool call cannot be the target of a following `tool` result).\n\nIn `ConvertMessages` (`internal/proxy/convert.go`), both append sites:\n\n```go\n// A message carrying no text and no tool call (an assistant turn whose\n// only content was reasoning, for example) converts to an empty part\n// list, which marshals as \"content\": null and is rejected upstream.\ncontentParts := parseContent(m.Content, toolNames)\nif len(contentParts) == 0 {\n    continue\n}\nccMsgs = append(ccMsgs, api.CCMessage{Role: m.Role, Content: contentParts})\n```\n\nand the same guard on the assistant-with-tool-calls branch at `:71`.\n\nAlternatively, return an empty non-nil slice from `parseContent` so it marshals as `[]` instead of `null` — but skipping is preferable, since an empty `content` array may itself be rejected.\n\n## Verification\n\nBuilt the current `main` unmodified and reproduced the 400 with all five forms above. With the guard applied:\n\n- all five forms now return 200\n- assistant tool-calls and their matching `tool` results are unchanged (round-trip verified)\n- `go vet ./...` clean, `go test ./...` passes\n\nHappy to send this as a PR if you'd like the patch.\n","author":{"url":"https://github.com/xue77777777777","@type":"Person","name":"xue77777777777"},"datePublished":"2026-09-17T09:21:13Z","url":"https://github.com/dev2k6/command-code-proxy-server/issues/10"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:7edecf02-d1f6-e9cb-321e-ab8af569892f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCAEE:13C947:FF006:14D0F2:6AEC08F4
html-safe-nonce9be9ca7ba332736dd30de70a29840866dd938f41c1cb471c75c65b634c11ae12
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQUVFOjEzQzk0NzpGRjAwNjoxNEQwRjI6NkFFQzA4RjQiLCJ2aXNpdG9yX2lkIjoiNjMxNTk0MjUwMzcwMTU0NzI1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac9d55e4094151919063b06f0a492bf93fa54ae94aab97e5b853ed00dabab05a71
hovercard-subject-tagissue:5485442881
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/dev2k6/command-code-proxy-server/10/issue_layout
twitter:imagehttps://opengraph.githubassets.com/621a78a06edf8b38e9e5d8e5867d48afa9a412b52b8c62f7b615313609fd7cb8/dev2k6/command-code-proxy-server/issues/10
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/621a78a06edf8b38e9e5d8e5867d48afa9a412b52b8c62f7b615313609fd7cb8/dev2k6/command-code-proxy-server/issues/10
og:image:altProblem ConvertMessages forwards assistant messages that have no text and no tool call as "content": null, which the upstream gateway rejects with a non-retryable 400. The whole request fails. Real...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamexue77777777777
hostnamegithub.com
expected-hostnamegithub.com
Noned063d52022f5f270ef55a70761d126c8085d492d3c251084b07781784c02dad4
turbo-cache-controlno-preview
go-importgithub.com/dev2k6/command-code-proxy-server git https://github.com/dev2k6/command-code-proxy-server.git
octolytics-dimension-user_id234830861
octolytics-dimension-user_logindev2k6
octolytics-dimension-repository_id1242849406
octolytics-dimension-repository_nwodev2k6/command-code-proxy-server
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1242849406
octolytics-dimension-repository_network_root_nwodev2k6/command-code-proxy-server
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release56e59340194011ba3cb6809acfa979ccbd174288
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/dev2k6/command-code-proxy-server/issues/10#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fdev2k6%2Fcommand-code-proxy-server%2Fissues%2F10
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fdev2k6%2Fcommand-code-proxy-server%2Fissues%2F10
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=dev2k6%2Fcommand-code-proxy-server
Reloadhttps://github.com/dev2k6/command-code-proxy-server/issues/10
Reloadhttps://github.com/dev2k6/command-code-proxy-server/issues/10
Reloadhttps://github.com/dev2k6/command-code-proxy-server/issues/10
dev2k6https://github.com/dev2k6
command-code-proxy-serverhttps://github.com/dev2k6/command-code-proxy-server
Codehttps://github.com/dev2k6/command-code-proxy-server
Issues4 (4)https://github.com/dev2k6/command-code-proxy-server/issues
Pull requests3 (3)https://github.com/dev2k6/command-code-proxy-server/pulls
Actionshttps://github.com/dev2k6/command-code-proxy-server/actions
Projectshttps://github.com/dev2k6/command-code-proxy-server/projects
Security and qualityhttps://github.com/dev2k6/command-code-proxy-server/security
Insightshttps://github.com/dev2k6/command-code-proxy-server/pulse
https://github.com/dev2k6/command-code-proxy-server
New issuehttps://github.com/login?return_to=https://github.com/dev2k6/command-code-proxy-server/issues/10
New issuehttps://github.com/login?return_to=https://github.com/dev2k6/command-code-proxy-server/issues/10
Assistant messages with empty content are sent as "content": null, causing a non-retryable 400https://github.com/dev2k6/command-code-proxy-server/issues/10#top
https://github.com/xue77777777777
xue77777777777https://github.com/xue77777777777
on Sep 17, 2026https://github.com/dev2k6/command-code-proxy-server/issues/10#issue-5485442881
Sign up for freehttps://github.com/signup?return_to=https://github.com/dev2k6/command-code-proxy-server/issues/10
Sign in to commenthttps://github.com/login?return_to=https://github.com/dev2k6/command-code-proxy-server/issues/10
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.