Repository navigation
fix(api): keep Quran Reflect query casing on content-catalog paths - #110
Open
marouanebatrone wants to merge 1 commit into
Open
marouanebatrone wants to merge 1 commit into
marouanebatrone wants to merge 1 commit into
Conversation
The content catalog includes the public Quran Reflect reads (`postsControllerFeed`, `postsControllerGetUserPost` and the post and comment reads). Their paths start with `/quran-reflect/v1`, so the request goes to Quran Reflect through the gateway, but `buildServiceUrl` chose the query key casing from the calling service. As a content call, every key was decamelized: `sortBy`, `postTypeIds`, `filter[verifiedOnly]` and `filter[references][0][chapterId]` went out as `sort_by`, `post_type_ids`, `filter[verified_only]` and `filter[references][0][chapter_id]`. Both the content and the Quran Reflect specs declare the camelCase names, and the same operations through `client.quranReflect.v1.raw` already keep them. Take the casing from the service that serves the path. Only cross-service paths change; content, search and analytics paths still send snake_case keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Problem
The content catalog includes the public Quran Reflect reads:
postsControllerFeed,postsControllerFindOne,postsControllerGetUserPost,postsControllerGetCommentsandpostsControllerGetAllComment. Their paths start with/quran-reflect/v1, sobuildServiceUrl(packages/api/src/sdk/fetcher.ts) sends them to Quran Reflect through the gateway. But it still picks the query key casing from the calling service, so these calls have their keys converted to snake_case as if they were content calls:The content spec (
openAPI/content/v4.json) and the Quran Reflect spec (openAPI/user-related-apis/v1.json) both declare these parameters in camelCase:sortBy,postTypeIds,filter[verifiedOnly],filter[postTypeIds],filter[tagsOperator],filter[referencesOperator]andfilter[references][0][chapterId]. The same operations called throughclient.quranReflect.v1.rawalready send them as written. So reading an ayah's reflections through the content catalog with an app token sends the reference and verified-only filters under names the API doesn't define.Change
buildServiceUrlnow takes the query key casing from the service that serves the path. A path that starts with another service's gateway prefix is served by that service, so the content catalog's Quran Reflect reads keep their camelCase keys, as they already do throughclient.quranReflect.v1.raw.isCrossServiceGatewayPath()becomesgatewayPathService(), which returns the service the path prefix belongs to, so the prefix is only matched once.Tests
Two new tests in
test/raw-operation.test.ts:buildServiceUrl("content", "/quran-reflect/v1/…")keepsfilter[references][0][chapterId],filter[verifiedOnly],postTypeIdsandsortBy, while content paths such as/chapters/1/infoand/content/api/v4/verses/by_key/1:1still sendinclude_resources,resource_idandper_page.client.content.v4.raw.postsControllerFeed()(app token) orclient.quranReflect.v1.raw.postsControllerFeed()(user token).Both fail on
mainwithexpected null to be '2', because the key arrived asfilter[references][0][chapter_id], and pass with the fix.Checks run locally on current
main(Node 26.8.1, pnpm 9.15.4)pnpm test(vitest, build and package smoke test): 29 files, 358 tests passed.pnpm lint --quiet,pnpm typecheckandpnpm build --filter=./packages/*: passed.pnpm --filter @quranjs/api size: within limits, unchanged frommain.fetcher.tsalready differs from Prettier's output onmainin unrelated places, and this diff adds no new differences.