fix(fmodata/better-auth): resolve OData metadata key lookup + upgrade better-auth to 1.5.x#124
Merged
eluce2 merged 4 commits intoproofgeist:mainfrom Mar 6, 2026
Conversation
- Upgrade better-auth from 1.4.11 to 1.5.4 - Replace createAdapter with createAdapterFactory (1.5 breaking change) - Replace getAdapter with direct adapter resolution in CLI (removed in 1.5) - Remove runAdapterTest from e2e (better-auth/adapters/test removed in 1.5) - Restore FMServerConnection import in e2e adapter test Made-with: Cursor
…tension FileMaker Server's OData $metadata endpoint returns the database name as the key without the .fmp12 file extension (e.g. "GMT_Web" instead of "GMT_Web.fmp12"). The Database.getMetadata() method was looking up data[this.databaseName] which always failed for databases constructed with the full filename, causing the migration CLI to throw: "Metadata for database "GMT_Web.fmp12" not found in response" Fix: fall back to the extension-stripped name when the full name is not found in the response. Full name still takes priority for servers that may return the key with the extension. Also corrects a secondary issue where calling getMetadata() without an explicit format argument (the default JSON path) would skip the JSON extraction branch entirely, returning the raw wrapper object instead of the database-scoped metadata. Adds unit tests covering: - Server returns key without .fmp12 (the primary bug scenario) - Server returns key with .fmp12 (backward compat) - Both keys present - full name wins - Neither key present - throws descriptive error - Works with explicit format: 'json' argument Made-with: Cursor
|
@chriscors is attempting to deploy a commit to the Proof Geist Team on Vercel. A member of the Team first needs to authorize it. |
@proofkit/better-auth
@proofkit/cli
create-proofkit
@proofkit/fmdapi
@proofkit/fmodata
@proofkit/typegen
@proofkit/webviewer
commit: |
…es without .fmp12 extension. Upgrade better-auth to 1.5.x, replacing createAdapter with createAdapterFactory and removing getAdapter.
…r result assertions Updated test assertions in FileMakerAdapter tests to use a more descriptive variable name for the user result, enhancing code readability and maintainability.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR ships two related fixes surfaced while investigating a bug in the
@proofkit/better-authmigration CLI:@proofkit/fmodata— metadata key lookup bug (fix):Database.getMetadata()was throwing when connecting to FileMaker Server because the OData$metadataendpoint returns the database name without the.fmp12extension as the response key (e.g."GMT_Web"), but theDatabaseinstance is constructed with the full filename ("GMT_Web.fmp12"). The key lookupdata[this.databaseName]always missed, crashing the migration CLI with a confusing error.@proofkit/better-auth— upgrade to Better Auth 1.5.x (feat): Better Auth 1.5 renamedcreateAdapter→createAdapterFactoryinbetter-auth/adaptersand removed thegetAdapterexport frombetter-auth/db. Updated the adapter and CLI to use the new APIs.Root Cause
The migration CLI calls
db.getMetadata()to compare existing FileMaker tables against the Better Auth schema.getMetadata()fetches/{db}/$metadataand then extractsdata["GMT_Web.fmp12"]. FileMaker's OData engine returns{ "GMT_Web": { ... } }— without the.fmp12extension — so the lookup returnedundefined, and the code threw before any migration logic ran. Regular queries were unaffected because they never callgetMetadata().Changes
packages/fmodata/src/client/database.tsgetMetadata()now falls back to the.fmp12-stripped database name when the full name is not found as a key in the OData response:format: 'json') code path previously gated onargs?.format === "json", which silently returned the raw wrapper object whenformatwas omitted. Logic inverted toformat === "xml"as the early-return so all JSON paths flow through the same extraction branch.packages/fmodata/tests/metadata.test.ts(new file)Five unit tests covering the metadata key resolution:
.fmp12— the primary bug scenario.fmp12— backward-compatformat: 'json'argumentpackages/better-auth/package.jsonbetter-authdependency from^1.4.11→^1.5.4packages/better-auth/src/adapter.tscreateAdapterimport withcreateAdapterFactoryfrombetter-auth/adapterspackages/better-auth/src/cli/index.tsgetAdapter(removed in Better Auth 1.5); replaced with direct factory invocation ofconfig.database(the adapter factory function stored on the config object)packages/better-auth/tests/e2e/adapter.test.tscreateAdapterFactoryAPITest Plan
pnpm --filter @proofkit/fmodata run test— 799 tests pass (5 new)pnpm --filter @proofkit/better-auth run test— 39 tests passpnpm --filter @proofkit/fmodata run typecheck— no errorspnpm --filter @proofkit/better-auth run typecheck— no errorsDiff Summary
Made with Cursor