Skip to content

fix: respect caller Accept header in fmodata; better typegen metadata error#220

Merged
eluce2 merged 2 commits intomainfrom
fix/fmodata-accept-header-override
Apr 23, 2026
Merged

fix: respect caller Accept header in fmodata; better typegen metadata error#220
eluce2 merged 2 commits intomainfrom
fix/fmodata-accept-header-override

Conversation

@eluce2
Copy link
Copy Markdown
Collaborator

@eluce2 eluce2 commented Apr 23, 2026

Summary

  • fmodata bug fix: _makeRequestEffect (filemaker-odata.ts) unconditionally set Accept: application/json, clobbering the Accept: application/xml that getMetadata({ format: "xml" }) passed in. Server returned JSON, the JSON branch parsed it into an object, that object was cast to `string` and handed to fast-xml-parser → `@proofkit/typegen` blew up with "No Edmx element found in XML" on every fmodata config. Fix: only apply the default Accept when the caller hasn't supplied one.
  • typegen DX: when the metadata response is missing `edmx:Edmx`, surface a 500-char excerpt and recognize common modes (empty body, JSON error payload, HTML login redirect) instead of the opaque "No Edmx element found in XML".

Repro: any `@proofkit/typegen` config with `type: "fmodata"` against current beta.

Test plan

  • `pnpm typecheck` clean in both packages
  • Verified fix end-to-end against a real FM Server (12 OData tables regenerated cleanly)
  • CI

🤖 Generated with Claude Code

Summary by CodeRabbit

Bug Fixes

  • Fixed issue where XML metadata requests were incorrectly overwritten by default headers, preventing proper XML response handling.
  • Enhanced error messages for OData metadata parsing failures to include response excerpts and identify common failure modes (empty responses, JSON instead of XML, HTML redirects).

eluce2 and others added 2 commits April 23, 2026 12:51
_makeRequestEffect overwrote caller Accept; getMetadata({format:"xml"})
got json back, mis-cast to string, broke typegen parseMetadata.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Detect empty/JSON/HTML responses and include 500-char excerpt instead
of opaque "No Edmx element found in XML".

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 23, 2026

🦋 Changeset detected

Latest commit: c031d74

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@proofkit/fmodata Patch
@proofkit/typegen Patch
@proofkit/better-auth Patch
@proofkit/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
proofkit-docs Ready Ready Preview Apr 23, 2026 5:54pm

Request Review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 23, 2026

Open in StackBlitz

@proofkit/better-auth

pnpm add https://pkg.pr.new/proofsh/proofkit/@proofkit/better-auth@220

@proofkit/cli

pnpm add https://pkg.pr.new/proofsh/proofkit/@proofkit/cli@220

create-proofkit

pnpm add https://pkg.pr.new/proofsh/proofkit/create-proofkit@220

@proofkit/fmdapi

pnpm add https://pkg.pr.new/proofsh/proofkit/@proofkit/fmdapi@220

@proofkit/fmodata

pnpm add https://pkg.pr.new/proofsh/proofkit/@proofkit/fmodata@220

@proofkit/typegen

pnpm add https://pkg.pr.new/proofsh/proofkit/@proofkit/typegen@220

@proofkit/webviewer

pnpm add https://pkg.pr.new/proofsh/proofkit/@proofkit/webviewer@220

commit: c031d74

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Walkthrough

This pull request fixes two separate issues: the Accept header in FileMaker OData requests is now preserved when explicitly set by callers, and metadata parsing error messages now include payload excerpts and identify common failure modes instead of a generic error.

Changes

Cohort / File(s) Summary
Changesets
.changeset/fix-fmodata-respect-caller-accept-header.md, .changeset/improve-typegen-metadata-error.md
Documentation of two patch-level fixes: Accept header preservation in fmodata and improved error diagnostics in typegen metadata parsing.
fmodata Accept Header Handling
packages/fmodata/src/client/filemaker-odata.ts
Modified _makeRequestEffect to check headers.has("Accept") before applying default Accept header, allowing callers to control content negotiation per-request.
typegen Metadata Error Diagnostics
packages/typegen/src/fmodata/parseMetadata.ts
Enhanced error handling in parseMetadata to normalize input to string, detect common failure modes (empty response, JSON vs. XML mismatch, HTML redirects), and include truncated payload excerpts in error messages.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: fixing the Accept header override in fmodata and improving typegen metadata error messages.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/fmodata-accept-header-override

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/typegen/src/fmodata/parseMetadata.ts (1)

76-77: Extract the HTML-detection window into a named constant.

200 is a magic number here; giving it a descriptive constant will keep this heuristic easier to tune.

♻️ Proposed tidy-up
 const RESPONSE_EXCERPT_LIMIT = 500;
+const HTML_DETECTION_PREFIX_LIMIT = 200;
@@
-  const lower = trimmed.slice(0, 200).toLowerCase();
+  const lower = trimmed.slice(0, HTML_DETECTION_PREFIX_LIMIT).toLowerCase();

As per coding guidelines, "Use meaningful variable names instead of magic numbers - extract constants with descriptive names".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/typegen/src/fmodata/parseMetadata.ts` around lines 76 - 77, Extract
the magic number 200 into a named constant (e.g., HTML_DETECTION_WINDOW = 200)
and replace trimmed.slice(0, 200) with trimmed.slice(0, HTML_DETECTION_WINDOW)
so the HTML-detection heuristic is configurable and self-documenting; update the
code near parseMetadata (where `trimmed` is sliced into `lower`) and ensure the
new constant is declared with an appropriate scope (module-level or
function-level) and a descriptive name like HTML_DETECTION_WINDOW.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/typegen/src/fmodata/parseMetadata.ts`:
- Around line 76-77: Extract the magic number 200 into a named constant (e.g.,
HTML_DETECTION_WINDOW = 200) and replace trimmed.slice(0, 200) with
trimmed.slice(0, HTML_DETECTION_WINDOW) so the HTML-detection heuristic is
configurable and self-documenting; update the code near parseMetadata (where
`trimmed` is sliced into `lower`) and ensure the new constant is declared with
an appropriate scope (module-level or function-level) and a descriptive name
like HTML_DETECTION_WINDOW.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c91ca9c5-bc86-4faa-9b1c-64300d26059a

📥 Commits

Reviewing files that changed from the base of the PR and between 564c9d2 and c031d74.

📒 Files selected for processing (4)
  • .changeset/fix-fmodata-respect-caller-accept-header.md
  • .changeset/improve-typegen-metadata-error.md
  • packages/fmodata/src/client/filemaker-odata.ts
  • packages/typegen/src/fmodata/parseMetadata.ts

@eluce2 eluce2 merged commit ced2127 into main Apr 23, 2026
14 checks passed
@eluce2 eluce2 deleted the fix/fmodata-accept-header-override branch April 23, 2026 17:58
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