[PR #50] [MERGED] fix: improve Go SDK parameter extraction and service disambiguation #207

Closed
opened 2026-03-15 11:53:24 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/awslabs/iam-policy-autopilot/pull/50
Author: @adpaco-aws
Created: 12/3/2025
Status: Merged
Merged: 12/5/2025
Merged by: @adpaco-aws

Base: mainHead: fix-go-struct-fields-extraction


📝 Commits (2)

  • bc6c411 fix: improve Go SDK parameter extraction and service disambiguation accuracy
  • 18d74dd refactor: update node kinds comparison to use constants

📊 Changes

14 files changed (+1028 additions, -127 deletions)

View changed files

📝 iam-policy-autopilot-policy-generation/src/extraction/go/disambiguation.rs (+344 -60)
📝 iam-policy-autopilot-policy-generation/src/extraction/go/extractor.rs (+595 -64)
📝 iam-policy-autopilot-policy-generation/src/extraction/go/features_extractor.rs (+1 -0)
📝 iam-policy-autopilot-policy-generation/src/extraction/go/mod.rs (+1 -0)
iam-policy-autopilot-policy-generation/src/extraction/go/node_kinds.rs (+43 -0)
📝 iam-policy-autopilot-policy-generation/src/extraction/go/waiter_extractor.rs (+1 -0)
📝 iam-policy-autopilot-policy-generation/src/extraction/mod.rs (+6 -0)
📝 iam-policy-autopilot-policy-generation/src/extraction/python/common/argument_extractor.rs (+5 -3)
📝 iam-policy-autopilot-policy-generation/src/extraction/python/disambiguation.rs (+2 -0)
📝 iam-policy-autopilot-policy-generation/src/extraction/python/disambiguation_tests.rs (+2 -0)
📝 iam-policy-autopilot-policy-generation/src/extraction/python/mod.rs (+1 -0)
iam-policy-autopilot-policy-generation/src/extraction/python/node_kinds.rs (+23 -0)
📝 iam-policy-autopilot-policy-generation/src/extraction/python/resource_direct_calls_extractor.rs (+2 -0)
📝 iam-policy-autopilot-policy-generation/src/extraction/sdk_model.rs (+2 -0)

📄 Description

Description of changes: Fixes two critical bugs in Go SDK method extraction that were causing incorrect service disambiguation and filtering of valid operations.

Problems Fixed

Incomplete struct field extraction

The extractor was using string parsing to extract field names from Go struct literals, which failed to reliably extract parameters. This prevented proper service disambiguation.

Fix: Implemented AST-based field extraction to accurately parse struct literals and extract field names directly from the syntax tree.

Case-sensitive parameter validation

AWS service models use inconsistent casing - some services use PascalCase while others use camelCase. Since the Go SDK always uses PascalCase, case-sensitive validation was incorrectly rejecting valid operations or matching them to the wrong services.

Fix: Changed parameter validation to use case-insensitive comparison for both valid parameter checks and required parameter checks.

Testing

Added 5 new tests covering:

  • Missing required parameters
  • Required parameter validation
  • Variable-based parameters
  • Service disambiguation by required parameters
  • Nested map keys in struct literals

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/awslabs/iam-policy-autopilot/pull/50 **Author:** [@adpaco-aws](https://github.com/adpaco-aws) **Created:** 12/3/2025 **Status:** ✅ Merged **Merged:** 12/5/2025 **Merged by:** [@adpaco-aws](https://github.com/adpaco-aws) **Base:** `main` ← **Head:** `fix-go-struct-fields-extraction` --- ### 📝 Commits (2) - [`bc6c411`](https://github.com/awslabs/iam-policy-autopilot/commit/bc6c411cb661830b3309133ab1545a3e6da4d2bb) fix: improve Go SDK parameter extraction and service disambiguation accuracy - [`18d74dd`](https://github.com/awslabs/iam-policy-autopilot/commit/18d74dd00d41fb663d46d42f1d21d7dc21309311) refactor: update node kinds comparison to use constants ### 📊 Changes **14 files changed** (+1028 additions, -127 deletions) <details> <summary>View changed files</summary> 📝 `iam-policy-autopilot-policy-generation/src/extraction/go/disambiguation.rs` (+344 -60) 📝 `iam-policy-autopilot-policy-generation/src/extraction/go/extractor.rs` (+595 -64) 📝 `iam-policy-autopilot-policy-generation/src/extraction/go/features_extractor.rs` (+1 -0) 📝 `iam-policy-autopilot-policy-generation/src/extraction/go/mod.rs` (+1 -0) ➕ `iam-policy-autopilot-policy-generation/src/extraction/go/node_kinds.rs` (+43 -0) 📝 `iam-policy-autopilot-policy-generation/src/extraction/go/waiter_extractor.rs` (+1 -0) 📝 `iam-policy-autopilot-policy-generation/src/extraction/mod.rs` (+6 -0) 📝 `iam-policy-autopilot-policy-generation/src/extraction/python/common/argument_extractor.rs` (+5 -3) 📝 `iam-policy-autopilot-policy-generation/src/extraction/python/disambiguation.rs` (+2 -0) 📝 `iam-policy-autopilot-policy-generation/src/extraction/python/disambiguation_tests.rs` (+2 -0) 📝 `iam-policy-autopilot-policy-generation/src/extraction/python/mod.rs` (+1 -0) ➕ `iam-policy-autopilot-policy-generation/src/extraction/python/node_kinds.rs` (+23 -0) 📝 `iam-policy-autopilot-policy-generation/src/extraction/python/resource_direct_calls_extractor.rs` (+2 -0) 📝 `iam-policy-autopilot-policy-generation/src/extraction/sdk_model.rs` (+2 -0) </details> ### 📄 Description *Description of changes:* Fixes two critical bugs in Go SDK method extraction that were causing incorrect service disambiguation and filtering of valid operations. ### Problems Fixed #### Incomplete struct field extraction The extractor was using string parsing to extract field names from Go struct literals, which failed to reliably extract parameters. This prevented proper service disambiguation. Fix: Implemented AST-based field extraction to accurately parse struct literals and extract field names directly from the syntax tree. #### Case-sensitive parameter validation AWS service models use inconsistent casing - some services use PascalCase while others use camelCase. Since the Go SDK always uses PascalCase, case-sensitive validation was incorrectly rejecting valid operations or matching them to the wrong services. Fix: Changed parameter validation to use case-insensitive comparison for both valid parameter checks and required parameter checks. ### Testing Added 5 new tests covering: - Missing required parameters - Required parameter validation - Variable-based parameters - Service disambiguation by required parameters - Nested map keys in struct literals By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-15 11:53:24 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/iam-policy-autopilot#207
No description provided.