-
Notifications
You must be signed in to change notification settings - Fork 3
fix(fmodata): strip otto prefix and .fmp12 from batch sub-request URLs #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+86
−14
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@proofkit/fmodata": patch | ||
| --- | ||
|
|
||
| Fix batch sub-request URLs to use canonical FileMaker OData path format. Strips the Otto proxy prefix (`/otto/`) and `.fmp12` file extension from database names in sub-request URLs inside multipart batch bodies, which are processed directly by FileMaker's OData engine. Also fix `InvalidLocationHeaderError` in batch insert/update sub-responses by gracefully handling missing Location headers (returns ROWID -1 instead of throwing). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { formatBatchRequest, toBatchSubRequestUrl } from "../src/client/batch-request"; | ||
|
|
||
| describe("toBatchSubRequestUrl", () => { | ||
| it("strips /otto/ prefix and .fmp12 extension", () => { | ||
| const result = toBatchSubRequestUrl( | ||
| "https://host.example.com/otto/fmi/odata/v4/GMT_Web.fmp12/bookings?$top=1&$select=_GMTNum", | ||
| ); | ||
| expect(result).toBe("/fmi/odata/v4/GMT_Web/bookings?$top=1&$select=_GMTNum"); | ||
| }); | ||
|
|
||
| it("strips .fmp12 extension without /otto/ prefix", () => { | ||
| const result = toBatchSubRequestUrl("https://host.example.com/fmi/odata/v4/GMT_Web.fmp12/bookings"); | ||
| expect(result).toBe("/fmi/odata/v4/GMT_Web/bookings"); | ||
| }); | ||
|
|
||
| it("handles URLs without /otto/ or .fmp12", () => { | ||
| const result = toBatchSubRequestUrl("https://host.example.com/fmi/odata/v4/MyDB/contacts"); | ||
| expect(result).toBe("/fmi/odata/v4/MyDB/contacts"); | ||
| }); | ||
|
|
||
| it("preserves query parameters", () => { | ||
| const result = toBatchSubRequestUrl( | ||
| "https://host.example.com/otto/fmi/odata/v4/MyDB.fmp12/contacts?$filter=name eq 'test'&$top=10", | ||
| ); | ||
| expect(result).toBe("/fmi/odata/v4/MyDB/contacts?$filter=name%20eq%20%27test%27&$top=10"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("formatBatchRequest sub-request URLs", () => { | ||
| it("uses canonical paths without /otto/ prefix or .fmp12 in sub-requests", () => { | ||
| const baseUrl = "https://host.example.com/otto/fmi/odata/v4/GMT_Web.fmp12"; | ||
| const { body } = formatBatchRequest( | ||
| [{ method: "GET", url: `${baseUrl}/bookings?$top=1&$select=_GMTNum` }], | ||
| baseUrl, | ||
| ); | ||
|
|
||
| // The sub-request line must use the canonical path | ||
| expect(body).toContain("GET /fmi/odata/v4/GMT_Web/bookings?$top=1&$select=_GMTNum HTTP/1.1"); | ||
| // Must NOT contain the otto prefix or .fmp12 in the request line | ||
| expect(body).not.toContain("/otto/"); | ||
| expect(body).not.toContain(".fmp12"); | ||
| }); | ||
|
|
||
| it("handles relative URLs by prepending baseUrl then transforming", () => { | ||
| const baseUrl = "https://host.example.com/otto/fmi/odata/v4/MyDB.fmp12"; | ||
| const { body } = formatBatchRequest([{ method: "GET", url: "/contacts?$top=5" }], baseUrl); | ||
|
|
||
| expect(body).toContain("GET /fmi/odata/v4/MyDB/contacts?$top=5 HTTP/1.1"); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Centralize minimal-response ROWID parsing and keep
processResponse()non-throwing.These two branches duplicate the same
Locationhandling, andthis.parseLocationHeader()can still throw on a malformed header. InprocessResponse(), that means a rejected promise instead of the usual{ data, error }result. A small helper would make the-1fallback explicit and keep parse failures on the structured error path.♻️ Proposed refactor
As per coding guidelines, "Use meaningful variable names instead of magic numbers - extract constants with descriptive names".
Also applies to: 293-300
🤖 Prompt for AI Agents