{"id":"XE-0706","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"277","source_url":"https://github.com/xeprotocol/xe/issues/277","reporter_id":7,"title":"docs/api.md: six wrong or missing statements about pending entries, block types, tunnel errors, lease limits, chat limits, and empty-body errors","area":"sdk-docs-web","claimed_tier":"minor","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-05T13:01:16.117719+00:00","updated_at":"2026-11-15T20:40:24.669460+00:00","source_created_at":"2026-11-05T13:00:45+00:00","told_at":"2026-11-08T20:19:09+00:00","status_changed_at":"2026-11-08T20:18:18.125525+00:00","url":"https://bounty.xe.network/XE-0706","body":"Six statements in docs/api.md disagree with the code in this tree. Each one is small on its own. Together they give a developer a wrong picture of how the API behaves. All six are in the same file, so they are filed here as one correction.\n\nSeverity: Minor. The program counts documentation errors as Minor, and nothing here moves funds or gives anyone a new capability. The damage is a developer following the document and getting a response the document did not describe.\n\nMethod: this was checked by reading docs/api.md line by line against api/handler.go, api/chat.go, api/tunnel.go, api/vm.go, core/types.go, core/ledger.go, and chat/envelope.go at HEAD 9787859 plus merge 02e9641b0. No live node was used. The code paths below leave no room for doubt, so no live probe is needed to confirm the wording is wrong, though a live probe would still be useful for the paging and tunnel cases.\n\n## 1. GET /pending/{address} does return Timestamp\n\ndocs/api.md says: \"Entries here are raw PendingSend with no Timestamp field.\"\n\nThe code says otherwise. handleGetPending in api/handler.go returns h.enrichPending(pending), the same function GET /pending uses. enrichPending builds a pendingEntry with Timestamp taken from the sending block, 0 if the block is not found. The Timestamp field on pendingEntry has no omitempty tag, so the key is always serialized.\n\nThe document even contradicts itself. The GET /pending section above it says each entry is enriched with the send block's Timestamp. A client following the per-address section would throw the field away, or assume the two endpoints return different shapes, when they return the same shape.\n\n## 2. lease_renew is missing from the block type list and the POST /blocks section\n\nThe section heading in docs/api.md lists POST /blocks/{send,receive,lease,lease_accept,lease_settle,lease_cancel,lease_force_settle,multisig_open,multisig_update,burn,mint}. The Block object reference table lists the type as one of send,receive,lease,lease_accept,lease_settle,lease_cancel,lease_force_settle,multisig_open,multisig_update,burn,mint,genesis. Neither list includes lease_renew.\n\nThe code serves POST /blocks/lease_renew in routes() in api/handler.go, and core/types.go defines BlockLeaseRenew as the block type \"lease_renew\". The document's own endpoint index lists POST /blocks/lease_renew, so the file disagrees with itself. A developer who trusts the type table would conclude lease_renew cannot be submitted.\n\nThe same index is missing GET /chat/auth/challenge. The route exists in api/handler.go and has its own section in the document, but the index lists only the other four chat rows, so a developer using the index to discover endpoints will not find the challenge step that has to come before reading chat.\n\nA smaller slip in the same file: the header says the document is derived from core/api/handler.go. The real path is api/handler.go.\n\n## 3. Tunnel 410 says \"lease settled\" in the document and \"lease not active\" in the code\n\ndocs/api.md lists 410 lease settled among the errors for POST /tunnel/{leaseHash}/tcp.\n\napi/tunnel.go returns 410 \"lease not active\" whenever the lease state is anything other than accepted, which covers created, settled, cancelled, unfulfilled, and expired alike. The rest of the error list in the document matches the code, so only the 410 line is wrong. A client that branches on the word \"settled\" to tell a settled lease from a created or cancelled one will never match, because the node never sends that word.\n\n## 4. POST /lease/request dimension limits are not documented\n\ndocs/api.md describes the request body as vcpus, memory_mb, disk_gb (uint64; at least one >=1 required), duration (uint64 secs, required), access_pub_key (optional).\n\nThe handler calls core.ValidateLeaseDimensions, which also enforces vcpus <= 4096, memory_mb <= 67,108,864, disk_gb <= 1,048,576, and 60 <= duration <= 31,536,000, each with its own error message. A request that satisfies everything the document states can still be rejected with a 400 the document never mentions, for example a 30 second duration or a two year duration.\n\n## 5. The 8,192 byte chat message limit is not documented, and invalid ?since= is treated differently by two endpoints\n\nchat/envelope.go sets MaxMessageBytes = 8192, and handleChatSend in api/chat.go returns 400 \"message exceeds maximum length of 8192 bytes\". The error list for POST /chat/send in docs/api.md does not mention this limit.\n\nSeparately, handleChatMessages in api/chat.go silently ignores a ?since= value it cannot parse and falls back to 0, while handleGetRecentBlocks returns 400 for a non-numeric ?since=, and the document records that 400 for /blocks/recent. The document for chat only says since is optional with a default of 0, and says nothing about an invalid value. A developer who mistypes since on chat gets a successful response that quietly drops the filter, while the same mistake on another endpoint is rejected.\n\nThis second half is closer to Info than Minor. The silent ignore is also how parsePagination treats invalid limit and offset on every list endpoint, so it reads as a consistent code pattern with one inconsistent endpoint, rather than a behavior bug. It is filed here as an inconsistency plus a documentation gap.\n\n## 6. An empty body does not return \"block type mismatch\"\n\ndocs/api.md says: \"An empty or type-mismatched body returns 400 block type mismatch.\"\n\nsubmitBlock in api/handler.go decodes the body first. An empty body fails the decode and returns 400 \"invalid request body\". Only a body that decodes but has the wrong type returns 400 \"block type mismatch\". The document merges two different error branches into one sentence that is wrong for the empty case.\n\n## Suggested fix\n\nCorrect the six statements in docs/api.md: add Timestamp to the per-address pending example and drop the \"raw PendingSend\" sentence; add lease_renew to the POST /blocks heading and the type list; add GET /chat/auth/challenge to the endpoint index; correct the header path to api/handler.go; change the tunnel 410 line to \"lease not active\"; list the ValidateLeaseDimensions bounds in the POST /lease/request section; add the 8,192 byte limit to the POST /chat/send errors and note how an invalid since is handled on chat; split the empty-body sentence so the empty case says \"invalid request body\".","patch_refs":[{"id":483,"repo":"xeprotocol/xe","kind":"pr","ref":"317","title":"docs(api): correct inaccurate statements across endpoint descriptions (fixes #277)","url":"https://github.com/xeprotocol/xe/pull/317","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-11-10T00:12:01.832547+00:00"}],"thread":[{"id":1175,"source":"github","source_ref":"6726599766","author":"Joseph Denne","team":true,"body":"Thanks for the careful read of the API document. We have confirmed the discrepancies you list and they are being corrected; we will update https://bounty.xe.network/XE-0706 when the change has landed.","created_at":"2026-11-08T20:19:09+00:00"}]}