Skip to content

Fix GET /api crash on server notification docs#16

Merged
dominicletz merged 5 commits into
mainfrom
fix/api-docs-notification-render
Jul 2, 2026
Merged

Fix GET /api crash on server notification docs#16
dominicletz merged 5 commits into
mainfrom
fix/api-docs-notification-render

Conversation

@dominicletz

Copy link
Copy Markdown
Member

Summary

  • Fixes FunctionClauseError on GET /api when rendering server-to-client notification endpoints (dio_ticket_request, dio_notify) that have no client request example
  • Skips the example request block when example_request is absent and labels the payload "Example notification" instead of "Example response"
  • Adds a notify/2 helper in Network.RpcDocs so notification examples are JSON-encoded strings like other RPC examples

Test plan

  • mix compile
  • Render api_docs.html.eex with Network.RpcDocs.all() and confirm no crash
  • Hit GET /api on a running node and verify the page loads
  • Confirm dio_ticket_request and dio_notify show notification examples without an empty request block

Made with Cursor

Guard nil example_request in the API docs template and encode notification examples via a shared notify/2 helper so html_escape always receives strings.

Co-authored-by: Cursor <cursoragent@cursor.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the API and RPC documentation generation. In lib/network/api_docs.html.eex, it conditionally displays the example request block and dynamically labels the response section as either "Example response" or "Example notification" depending on the presence of an example request. In lib/network/rpc_docs.ex, it introduces a notify/2 helper function to clean up the generation of JSON-RPC notification examples. Feedback was provided to use the more idiomatic Elixir Access syntax (doc[:example_request]) instead of mixing Map.get/2 and dot-notation, which helps prevent potential KeyError exceptions.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread lib/network/api_docs.html.eex Outdated
dominicletz and others added 4 commits July 3, 2026 00:53
Co-authored-by: Cursor <cursoragent@cursor.com>
Cover server notification endpoints that omit example_request and assert the HTML page renders without crashing.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add contributor testing guidelines, Plug.Test examples, and README links so bug fixes and new behavior include tests in every PR.

Co-authored-by: Cursor <cursoragent@cursor.com>
Document dio_ticket follow-up for dio_ticket_request and continued dio_message usage for dio_notify, with notification-first ordering in the code rail.

Co-authored-by: Cursor <cursoragent@cursor.com>
@dominicletz dominicletz merged commit 5d5d62a into main Jul 2, 2026
2 checks passed
@dominicletz dominicletz deleted the fix/api-docs-notification-render branch July 2, 2026 23:32
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.

1 participant