Skip to content

fix(agiloft): correct response parsing, add EWGetChoiceLineId tool - #4477

Merged
waleedlatif1 merged 2 commits into
stagingfrom
waleedlatif1/validate-agiloft
May 6, 2026
Merged

fix(agiloft): correct response parsing, add EWGetChoiceLineId tool#4477
waleedlatif1 merged 2 commits into
stagingfrom
waleedlatif1/validate-agiloft

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Fixed search_records and select_records to unwrap data.result before walking EWREST_* keys (was returning empty arrays)
  • Fixed attachment_info to read correct API field names (filePosition/fileName/size)
  • Added Accept: application/json headers to REST CRUD tools (Agiloft defaults to XML)
  • Changed remove_attachment HTTP method to DELETE
  • Added new EWGetChoiceLineId tool for resolving choice display values to internal IDs (needed for EWSelect WHERE clauses on choice fields)
  • Block bgColor changed from #FFFFFF to brand navy #001028
  • Saved search output schema fixes (id type, optional description)

Type of Change

  • Bug fix
  • New feature (EWGetChoiceLineId tool)

Testing

Tested manually. Typecheck, lint, and check:api-validation all pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercelBot commented May 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
docsSkippedSkippedMay 6, 2026 6:46pm

Request Review

@cursor

cursorBot commented May 6, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes Agiloft tool HTTP methods/headers and response parsing, which can affect live integrations if Agiloft instances behave differently than expected. Adds a new Agiloft operation and updates schemas/docs, so reviewers should sanity-check API compatibility and downstream consumers of output types.

Overview
Agiloft integration updates: adds a new agiloft_get_choice_line_id tool (and block/docs/registry wiring) to resolve choice-list display values to internal numeric IDs for EWSelect filtering.

Bug fixes & compatibility: fixes agiloft_search_records/agiloft_select_records parsing by unwrapping data.result and handling EWREST counts, corrects attachment_info field mapping, switches remove_attachment to DELETE, and adds Accept: application/json to CRUD-style calls to avoid Agiloft’s XML default.

Schema/docs polish: adjusts saved-search id to number (and makes description optional), tightens attach contract optionality, normalizes API route error handling via toError, and updates Agiloft branding color plus PostHog docs to use apiKey instead of personalApiKey.

Reviewed by Cursor Bugbot for commit 791ca00. Configure here.

@greptile-apps

greptile-appsBot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes several bugs in the Agiloft integration's response parsing and HTTP semantics, and adds a new EWGetChoiceLineId tool for resolving choice-field display values to internal IDs needed in EWSelect WHERE clauses.

  • Response parsing fixes: search_records and select_records now unwrap data.result before walking EWREST_* keys (previously always returned empty arrays); attachment_info corrects field names to filePosition/fileName; remove_attachment now correctly issues a DELETE request instead of GET.
  • JSON content negotiation: REST CRUD endpoints (create_record, update_record, delete_record, read_record) gain Accept: application/json headers so Agiloft returns JSON instead of its XML default; EW* endpoints are unaffected since they already use .json URL extensions.
  • New agiloft_get_choice_line_id tool: Handles multiple response shapes (bare number, string, wrapped object) and returns an explicit error message when no match is found; integrated into the block config, registry, and docs.

Confidence Score: 5/5

Safe to merge — all changes are targeted bug fixes or additive, with no regressions to existing tool contracts.

The changes correct clearly wrong behaviour (GET instead of DELETE, missing XML→JSON negotiation, wrong field names, skipped result unwrapping) and introduce a new, self-contained tool. Each fix is narrow and well-scoped; the new tool follows established patterns exactly and handles multiple response shapes defensively. No shared infrastructure is modified, and no existing output contracts change in a breaking way.

No files require special attention.

Important Files Changed

FilenameOverview
apps/sim/tools/agiloft/get_choice_line_id.tsNew EWGetChoiceLineId tool with robust multi-format response parsing and proper auth lifecycle via executeAgiloftRequest
apps/sim/tools/agiloft/search_records.tsFixed response parsing: unwraps data.result before EWREST_ key walking, handles string-encoded counts, removes dead branch
apps/sim/tools/agiloft/select_records.tsFixed totalCount to prefer result over data for count resolution, matching the search_records pattern
apps/sim/tools/agiloft/attachment_info.tsFixed field name mappings: filePosition→position, fileName→name, added fileSize as fallback for size
apps/sim/tools/agiloft/remove_attachment.tsCorrected HTTP method from GET to DELETE; response body is read once as text then parsed, avoiding double-consume
apps/sim/tools/agiloft/utils.tsAdded buildGetChoiceLineIdUrl with correct trimming and URL encoding for both fieldName and value
apps/sim/blocks/blocks/agiloft.tsAdds get_choice_line_id operation, new value input field, bgColor brand update, and extends fieldName condition array
apps/sim/tools/agiloft/types.tsNew AgiloftGetChoiceLineIdParams and AgiloftGetChoiceLineIdResponse types; choiceLineId typed as number

Sequence Diagram

sequenceDiagram
participant Client
participant ExecuteAgiloftRequest
participant AgiloftAPI
Client->>ExecuteAgiloftRequest: params (instanceUrl, kb, login, password, ...)
ExecuteAgiloftRequest->>AgiloftAPI: POST /ewws/EWLogin → Bearer token
AgiloftAPI-->>ExecuteAgiloftRequest: {access_token}
alt search_records / select_records
ExecuteAgiloftRequest->>AgiloftAPI: GET /ewws/EWSearch/.json or EWSelect/.json
AgiloftAPI-->>ExecuteAgiloftRequest: {result: [...]} or {EWREST_*}
Note over ExecuteAgiloftRequest: Unwrap data.result ?? data,<br/>then walk EWREST_ keys
else get_choice_line_id (new)
ExecuteAgiloftRequest->>AgiloftAPI: GET /ewws/EWGetChoiceLineId/.json?field=&value=
AgiloftAPI-->>ExecuteAgiloftRequest: number | string | {id:...} | {result:...}
Note over ExecuteAgiloftRequest: Multi-shape parse → choiceLineId
else REST CRUD (create/read/update/delete)
ExecuteAgiloftRequest->>AgiloftAPI: POST/GET/PUT/DELETE /ewws/REST/{kb}/{table} + Accept: application/json
AgiloftAPI-->>ExecuteAgiloftRequest: JSON record
else remove_attachment (fixed)
ExecuteAgiloftRequest->>AgiloftAPI: DELETE /ewws/EWRemoveAttachment (was GET)
AgiloftAPI-->>ExecuteAgiloftRequest: remaining count
end
ExecuteAgiloftRequest->>AgiloftAPI: POST /ewws/EWLogout (best-effort)
ExecuteAgiloftRequest-->>Client: ToolResponse
Loading

Reviews (2): Last reviewed commit: "fix(agiloft): address PR review feedback" | Re-trigger Greptile

Comment threadapps/sim/tools/agiloft/search_records.ts Outdated
Comment threadapps/sim/tools/agiloft/get_choice_line_id.ts
Comment threadapps/sim/tools/agiloft/utils.ts Outdated
Comment threadapps/sim/tools/agiloft/search_records.ts
@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 791ca00. Configure here.

@waleedlatif1
waleedlatif1 merged commit 6d4ffff into stagingMay 6, 2026
14 checks passed
@waleedlatif1
waleedlatif1 deleted the waleedlatif1/validate-agiloft branch May 6, 2026 18:55
waleedlatif1 added a commit that referenced this pull request May 7, 2026
…4477)
* fix(agiloft): correct response parsing, add EWGetChoiceLineId tool
* fix(agiloft): address PR review feedback
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@waleedlatif1