FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: Preserve pointer types in generic iterators by murarustefaan · Pull Request #409 · cloudquery/codegen · GitHub

feat: Preserve pointer types in generic iterators - #409

Merged
kodiakhq[bot] merged 1 commit into
mainfrom
fix/pointer-return-types
Feb 17, 2026
Merged

feat: Preserve pointer types in generic iterators#409
kodiakhq[bot] merged 1 commit into
mainfrom
fix/pointer-return-types

Conversation

murarustefaan commented Feb 17, 2026
edited
Loading

Copy link
Copy Markdown
Member

Release-As: v0.4.0

murarustefaan requested a review from a team as a code owner February 17, 2026 15:38
murarustefaan requested review from Copilot and erezrokah and removed request for a team February 17, 2026 15:38
murarustefaan added the automerge Add to automerge PRs once requirements are met label Feb 17, 2026

Copilot AI 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

This pull request enhances the generic type normalization logic to properly preserve pointer types in generic iterators, specifically addressing the need to handle types like iter.Seq2[*github.Artifact, error] where pointer prefixes must be maintained.

Changes:

  • Refactored normalizedGenericTypeName to handle multiple type parameters and extract pointer handling into a separate helper function
  • Added normalizeFullTypeName helper function to normalize individual type names while preserving pointer prefixes
  • Added comprehensive unit tests covering various generic type scenarios including pointers, multiple type parameters, and versioned imports

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
interfaces/generate.go Refactored type normalization logic by extracting pointer handling into normalizeFullTypeName and updating normalizedGenericTypeName to support multiple type parameters
interfaces/generate_test.go Added comprehensive unit tests for normalizedGenericTypeName covering single/multiple type parameters, pointer types, and versioned imports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread interfaces/generate.go
Comment thread interfaces/generate.go
typeName = typeName[1:]
}

versionPattern := regexp.MustCompile(`/v\d+\.`)

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The regex pattern is compiled on every function call. Since this function may be called multiple times during code generation (once per type parameter), consider moving the regex compilation to a package-level variable to improve performance. For example, declare var versionPattern = regexp.MustCompile(\/v\d+\.`)` at the package level and reuse it in this function.

Copilot uses AI. Check for mistakes.
Comment thread interfaces/generate.go
// Generic output types have the full import path in the string value, so we need to normalize it
pattern := regexp.MustCompile(`\[(.*?)\]`)
groups := pattern.FindStringSubmatch((str))
pattern := regexp.MustCompile(`\[(.*)\]`)

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The regex pattern is compiled on every function call. Since this function is called for each return type in method signatures, consider moving the regex compilation to a package-level variable to improve performance. For example, declare var genericTypePattern = regexp.MustCompile(\\[(.*)\]`)` at the package level and reuse it in this function.

Copilot uses AI. Check for mistakes.
Comment thread interfaces/generate.go
Comment on lines +170 to +172
if versionPattern.MatchString(typeName) {
// Example typeName: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appconfiguration/armappconfiguration/v2.ConfigurationStoresClientCreateResponse
importName = parts[len(parts)-2] + "." + strings.Split(parts[len(parts)-1], ".")[1]

Copilot AI Feb 17, 2026

Copy link

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Potential index out of bounds error. The code assumes that when versionPattern matches, parts[len(parts)-1] (the last path segment) will contain a dot and can be safely split to access index [1]. While this is true for well-formed versioned import paths like armappconfiguration/v2.ConfigurationStoresClientListResponse, malformed input could cause a panic. Consider adding a bounds check or using a more defensive approach, such as checking the length of the split result before accessing index [1].

Suggested change
if versionPattern.MatchString(typeName) {
// Example typeName: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appconfiguration/armappconfiguration/v2.ConfigurationStoresClientCreateResponse
importName = parts[len(parts)-2] + "." + strings.Split(parts[len(parts)-1], ".")[1]
if versionPattern.MatchString(typeName) && len(parts) >= 2 {
// Example typeName: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appconfiguration/armappconfiguration/v2.ConfigurationStoresClientCreateResponse
lastParts := strings.Split(parts[len(parts)-1], ".")
if len(lastParts) >= 2 {
importName = parts[len(parts)-2] + "." + lastParts[1]
}

Copilot uses AI. Check for mistakes.
kodiakhq Bot merged commit d4fe386 into main Feb 17, 2026
15 checks passed
kodiakhq Bot deleted the fix/pointer-return-types branch February 17, 2026 15:50
kodiakhq Bot pushed a commit that referenced this pull request Feb 17, 2026
🤖 I have created a release *beep* *boop*
---


## [0.3.37](v0.3.36...v0.3.37) (2026-02-17)


### Features

* Preserve pointer types in generic iterators ([#409](#409)) ([d4fe386](d4fe386))


### Bug Fixes

* **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.94.2 ([#407](#407)) ([41c4bc3](41c4bc3))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
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

Labels

automerge Add to automerge PRs once requirements are met

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL