Repository navigation
Conversation
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.
What does this PR do?
Draft implementation PR for review in the
endformdev/emdashfork. No upstream PR has been opened.Fixes media folder search returning HTTP 500 on Cloudflare D1 for long search terms. The repository wraps the normalized term in
%…%and escapes literal wildcard characters. D1 limits LIKE patterns to 50 bytes, so a 49-character ASCII term already exceeds the limit; Unicode normalization and escaping can make shorter inputs fail too.Reproduction on a Cloudflare fixture:
"a".repeat(48) + "b".GET /_emdash/api/media/folders?q=...endpoint.D1_ERROR: LIKE or GLOB pattern too complex: SQLITE_ERRORand the endpoint returns 500. The same search succeeds with the fix.Use a parameterized literal substring predicate:
instron SQLite/D1 andstrposon PostgreSQL. This retains the existing normalization, complete search term, literal%/_/backslash matching, ordering and cursor pagination. It adds no queries or schema changes. Truncating the term would incorrectly return folders that share only its prefix.Related issue/design: none; this is a reproduced bug fix.
Type of change
Your connection to this change
Encountered while exercising EmDash's media library against a built Cloudflare fixture for the Endform integration. Direct requests reproduced it without Endform. This PR is based on the fork's
mainand contains none of the benchmark configuration changes.Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runAI assistance disclosure
Screenshots / test output
Screenshots: not applicable; no UI components or layouts changed.
One regression test runs against real workerd/D1. It searches for a 49-character substring and excludes a folder differing only in the last character, guarding against both the D1 exception and accidental truncation. The shared search-test helper and extra SQLite/PostgreSQL cases have been removed to keep this patch small.
No migration or configuration change is required.