Skip to content

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

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

fix(agiloft): correct response parsing, add EWGetChoiceLineId tool#4477
waleedlatif1 merged 2 commits intostagingfrom
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
Copy link
Copy Markdown

vercel Bot commented May 6, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 6, 2026 6:46pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 6, 2026

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
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 6, 2026

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

Filename Overview
apps/sim/tools/agiloft/get_choice_line_id.ts New EWGetChoiceLineId tool with robust multi-format response parsing and proper auth lifecycle via executeAgiloftRequest
apps/sim/tools/agiloft/search_records.ts Fixed response parsing: unwraps data.result before EWREST_ key walking, handles string-encoded counts, removes dead branch
apps/sim/tools/agiloft/select_records.ts Fixed totalCount to prefer result over data for count resolution, matching the search_records pattern
apps/sim/tools/agiloft/attachment_info.ts Fixed field name mappings: filePosition→position, fileName→name, added fileSize as fallback for size
apps/sim/tools/agiloft/remove_attachment.ts Corrected HTTP method from GET to DELETE; response body is read once as text then parsed, avoiding double-consume
apps/sim/tools/agiloft/utils.ts Added buildGetChoiceLineIdUrl with correct trimming and URL encoding for both fieldName and value
apps/sim/blocks/blocks/agiloft.ts Adds get_choice_line_id operation, new value input field, bgColor brand update, and extends fieldName condition array
apps/sim/tools/agiloft/types.ts New 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 thread apps/sim/tools/agiloft/search_records.ts Outdated
Comment thread apps/sim/tools/agiloft/get_choice_line_id.ts
Comment thread apps/sim/tools/agiloft/utils.ts Outdated
Comment thread apps/sim/tools/agiloft/search_records.ts
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 staging May 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 free to 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