fix: double-encoded SoQL wildcard broke agency search - #6
Merged
Conversation
The $where value embedded %25 and encodeURIComponent output, which URLSearchParams.set then encoded again — Socrata received a literal '%25NAME%25' pattern (with %20 for spaces) instead of the % wildcard, so agency matches with spaces or special characters silently failed. Per the SoQL like docs (https://dev.socrata.com/docs/functions/like.html) the wildcard is a literal % in the query; %25 is only its URL encoding, which the HTTP layer already applies once. Build the SoQL value unencoded (escaping single quotes by doubling) and let searchParams.set do the single encoding pass. Test written first; it fails against the old code and passes now. Also fix the test script glob (node --test with a bare directory arg fails on newer Node). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jul 6, 2026
noneck
added a commit
that referenced
this pull request
Jul 6, 2026
…refresh - Bump package.json/lockfile to 1.0.2. - Server reads its version from package.json via createRequire instead of a hardcoded string. - CHANGELOG: move Unreleased items into 1.0.2 (double-encoding fix #6, SoQL escaping + enum enforcement + NY-timezone today + error detail #7, hono bump #4, CI #3, release automation #8). - README: Claude Code config updated to .mcp.json / claude mcp add; add npm test instructions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
noneck
added a commit
that referenced
this pull request
Jul 6, 2026
* fix: SoQL escaping, NY-timezone today, error detail - Add soqlString() helper (quote-doubling) and use it in every $where builder: getNoticesByType, getNoticesByAgency, getNoticesByDateRange. - Validate notice_type with z.enum (mirrors the advertised tool enum, now derived from a single NOTICE_TYPES constant) and date params as YYYY-MM-DD. - getOpenSolicitations: compute "today" in America/New_York (nyToday()) instead of UTC, which dropped same-day deadlines after 8pm ET. - Include the (truncated, 300-char) Socrata error body in thrown errors. - Live-verified 2026-07-06: dataset's distinct type_of_notice_description values exactly match the hardcoded lists/enum (10 values, plus null rows); all start_date values are midnight, so the <= end bound is correct (documented in code). - Tests: escaping regressions, injected-clock NY-date checks (EDT/EST), error-body inclusion + truncation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * chore(release): 1.0.2 — version from package.json, changelog, README refresh - Bump package.json/lockfile to 1.0.2. - Server reads its version from package.json via createRequire instead of a hardcoded string. - CHANGELOG: move Unreleased items into 1.0.2 (double-encoding fix #6, SoQL escaping + enum enforcement + NY-timezone today + error detail #7, hono bump #4, CI #3, release automation #8). - README: Claude Code config updated to .mcp.json / claude mcp add; add npm test instructions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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 was broken
getNoticesByAgencybuilt its SoQL$wherevalue with%25andencodeURIComponent(agencyName)already baked in, thenURLSearchParams.setencoded the whole value a second time. Socrata received a literal%25NAME%25pattern (with%20for spaces) instead of the%wildcard, soget_notices_by_agencyLIKE matches — especially agency names with spaces or special characters — silently failed (empty results).Fix
Per the SoQL
likedocs, the wildcard is a literal%in the query;%25is only its URL encoding, which the HTTP layer already applies once. The SoQL value is now built unencoded (single quotes escaped by doubling per SQL rules) andURLSearchParamsperforms the single encoding pass.Adds a minimal
node:testregression test (test/encoding.test.mjs) that mocksfetch, asserts the decoded$wherecontains the literal%wildcard and raw agency name, and that the raw query string contains%25but not%2525. Adds thenpm testscript to run it.Test plan
npm run build— cleansrc/city-record.ts): actual'%25Parks%20%26%20Recreation%25'vs expected'%Parks & Recreation%'npm testpasses with the fixNote
Draft PR #5 (
refactor/mcpserver-migration) contains this same fix and will need a rebase after this merges.🤖 Generated with Claude Code