Skip to content

Fix circular JSON error in error handling and empty query in findRecords#1

Open
neilwjsimpson wants to merge 1 commit intomaxpetrusenko:mainfrom
Onroute-io:fix/circular-json-and-empty-query
Open

Fix circular JSON error in error handling and empty query in findRecords#1
neilwjsimpson wants to merge 1 commit intomaxpetrusenko:mainfrom
Onroute-io:fix/circular-json-and-empty-query

Conversation

@neilwjsimpson
Copy link

Summary

  • Circular JSON crash in error handlers: error.response (full Axios response object with circular refs ClientRequest <-> IncomingMessage) was included in debug log objects and passed to JSON.stringify, throwing "Converting circular structure to JSON" inside catch blocks and masking the original error. Fixed by extracting only serializable properties (data, status) and wrapping stringify in a safety net.
  • Empty query crash in findRecords: When called without a query, an empty array [] was sent to the _find endpoint, which FileMaker rejects. Fixed by routing to GET /layouts/{layout}/records when no query is provided.

Test plan

  • Call fm_find_records with a layout name and no query — should return records instead of crashing
  • Call fm_find_records with a layout name and a query — should still use _find endpoint correctly
  • Trigger any error (e.g. invalid layout name) — should return a readable error message instead of "Converting circular structure to JSON"

🤖 Generated with Claude Code

… findRecords

Two bugs fixed:

1. Error handlers included `error.response` (full Axios response object) in
   debug log objects, then called JSON.stringify on them. Axios response objects
   contain circular references (ClientRequest <-> IncomingMessage), causing
   "Converting circular structure to JSON" to be thrown inside catch blocks,
   masking the original error. Fixed by extracting only serializable properties
   (data, status) and wrapping the stringify in a try/catch safety net.

2. findRecords sent an empty query array [] to the _find endpoint when no
   query was provided. The FileMaker Data API rejects empty query arrays.
   Fixed by using GET /layouts/{layout}/records (list all records) when no
   query is specified, and POST _find only when a query is provided.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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