PDX-478: fix(mcp): parse .testproject connections and resolve env via associations#171
Merged
Merged
Conversation
… associations RCA: provar_connection_list returned 0 connections on every real Provar project (surveyed 7) because parseConnectionList traversed connectionClass.connection[] but the actual .testproject XML nests each <connection> under a <connections> wrapper. parseEnvironmentList separately read @connectionName and @url attributes that do not exist on <environment> elements — the connection link is in <associations><association connectionId="..."/></associations>, keyed to the connection's @id, and per-env URLs live on the matching connection's <connectionUrl @envid="<env.@Guid>"/> entry. The existing test fixture used the flattened (broken) XML shape that the buggy code expected, so CI never caught either bug. Fix: Traverse connectionClass.connections.connection[]. Build a connection-id-to-info map containing the default URL (the connectionUrl with no @envid) and a map of envId-to-URL overrides. Resolve environment.connection by mapping associations.association[0].@connectionId back to the connection name via that map, and use the env-specific URL when env.@Guid matches a connectionUrl.@envid. Handle empty <associations> (string-empty per real Provar XML) gracefully. Replace the fixture to mirror real .testproject XML and add tests for env→connection resolution, env-specific URL via @Guid, default-URL selection, and empty-associations. Verified non-zero connection counts and correct env→connection resolution across 7 real projects (provar-manager-regression, Agentforce, ExperienceCloud, FinancialServices, PQP, ProvarDXGrid, TrialProject). All 1109 unit tests pass; 54 smoke responses pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Quality Orchestrator🟢 LOW · 🧪 Tests to Run · Running 1 of 50 tests
▶ Run commandnpx vitest run \
unit/mcp/connectionTools.test.ts⚡ quality-orchestrator · |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes .testproject parsing for provar_connection_list so it matches real Provar project XML structure and correctly resolves environment-to-connection associations.
Changes:
- Parses connections from
connectionClass.connections.connection[]with default and environment-specificconnectionUrlentries. - Resolves environment connections through
associations.association[].connectionId. - Updates unit fixtures and assertions to cover real XML shape and empty associations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/mcp/tools/connectionTools.ts |
Updates connection and environment parsing logic for real .testproject XML. |
test/unit/mcp/connectionTools.test.ts |
Replaces flattened fixture with realistic XML and adds regression coverage for environment URL/association behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Fixes both parser bugs in
src/mcp/tools/connectionTools.tsthat madeprovar_connection_listeffectively non-functional on every real Provar project.parseConnectionListnow traversesconnectionClass.connections.connection[](the real XML shape) instead ofconnectionClass.connection[]parseEnvironmentListnow resolves the environment's connection by walkingassociations.association[].@connectionIdand looking up the name from the connection ID map. Environment-specific URLs are matched by environment@guidagainstconnectionUrl.@envId<associations></associations>(real-world edge case fromTrialProject) is handled gracefully — returnsconnection: ''without crashingLinked: PDX-478
Why this was missed
The existing test fixture used a flattened XML shape (
<connectionClass><connection name=... url=.../></connectionClass>and<environment connectionName=... url=.../>) that did not exist in any real Provar.testprojectfile — but exactly matched the buggy parser code. The fixture has been rewritten to mirror the real XML produced by Provar Desktop, including the<connections>wrapper,<connectionUrls><connectionUrl @envId=.../>per-env URL list, and<associations><association @connectionId=.../>environment-to-connection link.Impact (pre-fix baseline)
Surveyed 7 real Provar projects — every one returned 0 connections:
connection_listreturnedPost-fix: every project returns its full connection list and environment-to-connection links resolve correctly.
Test plan
yarn compilecleanyarn lintcleannode scripts/mcp-smoke.cjs— 54/54 PASSfields=connections.name,connections.type) verified end-to-end on real data — previously vacuous due to empty connection arrays<associations>edge case (TrialProject) handled without crashTest coverage added
New assertions in
test/unit/mcp/connectionTools.test.ts:associations[@connectionId]connectionUrl.@envIdmatches env@guid<associations>returnsconnection: ''without crashingurluses defaultconnectionUrl(entry without@envId)🤖 Generated with Claude Code