Skip to content

fix(qdev): configuration and execution not working with iam auth#8785

Open
ReeceXW wants to merge 2 commits intoapache:mainfrom
ReeceXW:fix/qdeveloper-iam-role-auth
Open

fix(qdev): configuration and execution not working with iam auth#8785
ReeceXW wants to merge 2 commits intoapache:mainfrom
ReeceXW:fix/qdeveloper-iam-role-auth

Conversation

@ReeceXW
Copy link
Copy Markdown
Contributor

@ReeceXW ReeceXW commented Mar 20, 2026

Summary

In the UI you are able to choose IAM authentication instead of an access key and secret but the API doesn't actually support this; it will just fail. I've added the type parameter to the API and the necessary AWS configuration to make this work.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. component/plugins This issue or PR relates to plugins pr-type/bug-fix This PR fixes a bug labels Mar 20, 2026
@klesh klesh requested a review from warren830 March 23, 2026 14:33
@klesh
Copy link
Copy Markdown
Contributor

klesh commented Mar 23, 2026

@warren830, could you please review this PR when you have a moment? Thank you!

Copy link
Copy Markdown
Contributor

@warren830 warren830 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR — overall clean and well-scoped. IAM credential chain handling is correct, backward compatibility is solid (defaults to access_key, migration backfills existing rows), and test coverage hits the key paths.

One additional concern not tied to a specific diff line:

Potential bug (medium): MergeFromRequest in models/connection.go uses DecodeMapStruct to overwrite fields from the request body. If a PATCH request omits authType, the field may be decoded as "", which then silently falls back to "access_key" via the validation default. This could unexpectedly flip an iam_role connection back to access_key. Consider adding the same guard pattern used for SecretAccessKey — preserve the existing AuthType when the incoming value is empty.

A few inline suggestions below — #1 (mutation in validation) and the MergeFromRequest issue above are worth addressing before merge; the rest are nice-to-haves.

type QDevConn struct {
// AccessKeyId for AWS
// AuthType determines how to authenticate with AWS: "access_key" or "iam_role"
AuthType string `mapstructure:"authType" json:"authType"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion (low): "access_key" and "iam_role" are repeated across validation, tests, migration, and both client files. Consider defining constants:

const (
    AuthTypeAccessKey = "access_key"
    AuthTypeIAMRole   = "iam_role"
)

This prevents typo-driven bugs and makes future additions easier to grep for.

return errors.Default.New("SecretAccessKey is required")
// Default to access_key auth type if not specified
if connection.AuthType == "" {
connection.AuthType = "access_key"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion (medium): A validation function ideally shouldn't mutate its input. Setting the default AuthType here means validateConnection has a side effect that callers may not expect. Consider moving the defaulting logic to a dedicated normalizeConnection() step (or into the caller) and keeping validateConnection pure.

}
// Only set static credentials for access_key auth; IAM role uses the default credential chain
if !connection.IsIAMRoleAuth() {
cfg.Credentials = credentials.NewStaticCredentials(connection.AccessKeyId, connection.SecretAccessKey, "")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit (low): This block is nearly identical to identity_client.go lines 51-59. A small helper like newAWSSession(conn *models.QDevConnection, region string) (*session.Session, error) would DRY this up. Not blocking — just a suggestion for a follow-up cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/plugins This issue or PR relates to plugins pr-type/bug-fix This PR fixes a bug size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants