Fix document/organization name filtering (client-side substring match) - #5
Open
jason-sager wants to merge 1 commit into
Open
Fix document/organization name filtering (client-side substring match)#5jason-sager wants to merge 1 commit into
jason-sager wants to merge 1 commit into
Conversation
The IT Glue API does not support filter[name] on the documents endpoint (its only documented filter is filter[document_folder_id]), and where filter[name] exists on other resources it is exact whole-string match. The server sent filter[name]=<term> anyway; the API silently ignored it and the two-call root+folder merge returned the organization's entire library — even though the tool advertised "partial match." - Add ITGlueClient.getAll() to fully paginate an endpoint, with termination guards (hard page cap, empty-page break, non-advancing next_page break). - itglue_list_documents / itglue_list_organizations: match filter_name as a case-insensitive substring client-side over the full list, then paginate. Exact filters (id, type, status) stay server-side. - Fix the double-counted total in list_documents browse mode (was rootResult.total_count + folderResult.total_count). - Make wording truthful in both schemas, both tool descriptions, the server instructions block, and the README. Tests: add getAll pagination/guard tests and search-mode tests; update the assertions that encoded the old on-the-wire filter[name] behavior. 194 pass. 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.
Problem
itglue_list_documents(anditglue_list_organizations) advertisefilter_nameas a "partial match", but it doesn't filter at all — a name-filtered query returns the organization's entire document library.Root cause: the IT Glue API's documents relationship endpoint does not support
filter[name](its only documented filter isfilter[document_folder_id]), and wherefilter[name]exists on other resources it is exact whole-string match, never substring. The server sendsfilter[name]=<term>faithfully, but the API silently ignores the unrecognized param, so the two-call root + folder merge returns everything. This also contradicts the server's own instructions block, which says filters are exact-match.There's also a secondary bug:
list_documentsreports the total asrootResult.total_count + folderResult.total_count, which double-counts.Fix
Move name matching client-side, where substring matching is actually possible:
ITGlueClient.getAll()— fully paginates an endpoint atpage[size]=1000, with termination guards (hard page cap, empty-page break, non-advancingnext_pagebreak).itglue_list_documents: whenfilter_nameis set, fetch all documents (root + folder), dedupe by id, match by case-insensitive substring, then paginate the filtered list client-side.filter_id(a genuine server-side exact match) stays on the wire.itglue_list_organizations: same treatment via a singlegetAllover/organizations; id/type/status filters stay server-side.filter_name) is unchanged except the total is now the deduped row count instead of the double-counted sum.Notes / trade-offs
2 × ceil(docCount/1000)requests for documents; well within the 3000-req/5-min limit). Preferfilter_idwhen the exact ID is known.Tests
getAllunit tests (multi-page accumulation, all three guards,page[size]=1000).filter[name]behavior and the double-counted total.npm test→ 194 passing;tsc --noEmitclean.🤖 Generated with Claude Code