Skip to content

🧹 Update go-atlassian to v2.11.0 and add nil safety guards#6404

Open
tas50 wants to merge 1 commit intomainfrom
tas50/atlassian
Open

🧹 Update go-atlassian to v2.11.0 and add nil safety guards#6404
tas50 wants to merge 1 commit intomainfrom
tas50/atlassian

Conversation

@tas50
Copy link
Copy Markdown
Member

@tas50 tas50 commented Jan 16, 2026

Summary

  • Update go-atlassian from v1 to v2.11.0 (latest)
  • Add nil guards for all pointer fields in the v2 library (Creator, AvatarURLs, Project, Status, IssueType, Created) to prevent nil pointer panics
  • Rebase onto main (cnquery→mql v13 rename)

Test plan

  • Build the atlassian provider: make providers/build/atlassian
  • Verify Jira issues query works with valid credentials
  • Verify no panic when issue fields are nil (e.g., issues without a creator)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 16, 2026

Test Results

5 397 tests  ±0   5 393 ✅ ±0   2m 20s ⏱️ -1s
  411 suites ±0       4 💤 ±0 
   31 files   ±0       0 ❌ ±0 

Results for commit 06addbd. ± Comparison against base commit e92d14d.

♻️ This comment has been updated with latest results.

@tas50 tas50 changed the title Update the atlassian provider to the latest library 🧹 Update the atlassian provider to the latest library Jan 17, 2026
@tas50 tas50 marked this pull request as ready for review January 18, 2026 00:42
Comment thread providers/atlassian/resources/atlassian_jira.go
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Atlassian provider to use the latest go-atlassian v2 module and adapts the provider implementation to breaking API changes, primarily around import paths, field names, and Jira date handling.

Changes:

  • Bumped github.com/ctreminiom/go-atlassian dependency to github.com/ctreminiom/go-atlassian/v2 v2.9.0 and updated all Atlassian connection packages to use the new v2 import paths.
  • Adjusted Jira resource code to use the new AvatarURLs field and the new typed Created field (no longer parsing a string timestamp, but converting from the library’s time type), removing the now-unused JIRA_TIME_FORMAT constant.
  • Cleaned up the Atlassian LR manifest by removing empty fields: {} entries and refreshed go.sum for updated transitive dependencies (e.g., gjson, go-containerregistry, go-querystring).

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
providers/atlassian/resources/atlassian_jira.go Updates Jira resource logic to match the v2 client: switches to AvatarURLs fields and converts the new typed Created value to time.Time, removing the obsolete time format constant.
providers/atlassian/resources/atlassian.lr.manifest.yaml Removes redundant empty fields: {} entries for the root atlassian resource and atlassian.admin.user.products, leaving the rest of the manifest unchanged.
providers/atlassian/go.mod Switches to github.com/ctreminiom/go-atlassian/v2 v2.9.0 and adds/updates indirect dependencies required by the new version.
providers/atlassian/go.sum Regenerates dependency checksums to reflect the new go-atlassian v2 module and updated transitive libraries (e.g., gjson, go-containerregistry, go-querystring).
providers/atlassian/connection/scim/connection.go Updates SCIM connection to use github.com/ctreminiom/go-atlassian/v2/admin while keeping authentication and validation logic the same.
providers/atlassian/connection/jira/connection.go Updates Jira connection to use github.com/ctreminiom/go-atlassian/v2/jira/v2 while preserving host/user/token handling and the auth check.
providers/atlassian/connection/confluence/connection.go Updates Confluence connection to import github.com/ctreminiom/go-atlassian/v2/confluence with unchanged client setup.
providers/atlassian/connection/admin/connection.go Updates Admin connection to import github.com/ctreminiom/go-atlassian/v2/admin with existing token-based auth and validation.

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

Comment thread providers/atlassian/resources/atlassian_jira.go
Comment thread providers/atlassian/resources/atlassian_jira.go
@tas50 tas50 force-pushed the tas50/atlassian branch from b9843da to 4a61760 Compare March 2, 2026 05:17
mondoo-code-review[bot]

This comment was marked as resolved.

@tas50 tas50 force-pushed the tas50/atlassian branch from 4a61760 to c93c48e Compare March 11, 2026 18:50
@mondoo-code-review mondoo-code-review Bot dismissed their stale review March 11, 2026 18:51

Superseded by new review

Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review Bot left a comment

Choose a reason for hiding this comment

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

Atlassian provider library upgrade may panic on nil Creator field

Comment thread providers/atlassian/resources/atlassian_jira.go Outdated
@tas50 tas50 force-pushed the tas50/atlassian branch from c93c48e to 84cb9e1 Compare March 11, 2026 18:52
Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review Bot left a comment

Choose a reason for hiding this comment

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

Atlassian provider library upgrade from v1 to v2 with adapted field access patterns.

Additional findings (file/line not in diff):

  • 🟡 providers/atlassian/resources/atlassian_jira.go:243issue.Fields.Project, issue.Fields.Status, and issue.Fields.IssueType are accessed without nil checks (lines 243-249). If the v2 library changed these to pointer types (as it did with Created and potentially Creator), these will panic on nil dereference. Verify whether these are value types or pointers in the v2 API.

Comment thread providers/atlassian/resources/atlassian_jira.go
- Changed github.com/ctreminiom/go-atlassian v1.6.1 → github.com/ctreminiom/go-atlassian/v2 v2.9.0
- Update breaking changes in the new library:
  - AvatarUrls → AvatarURLs: Field was renamed for Go naming conventions (lines 50, 235)
  - issue.Fields.Created type change: Changed from string to *models.DateTimeScheme (which is a type alias for time.Time). Updated the parsing logic from:

    created, err := time.Parse(JIRA_TIME_FORMAT, issue.Fields.Created)

    to

    var created time.Time
    if issue.Fields.Created != nil {
      created = time.Time(*issue.Fields.Created)
    }

Signed-off-by: Tim Smith <tsmith84@gmail.com>
@tas50 tas50 force-pushed the tas50/atlassian branch from 84cb9e1 to 06addbd Compare March 11, 2026 18:56
@tas50 tas50 changed the title 🧹 Update the atlassian provider to the latest library 🧹 Update go-atlassian to v2.11.0 and add nil safety guards Mar 11, 2026
Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review Bot left a comment

Choose a reason for hiding this comment

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

Library upgrade adds nil-safety for issues but misses it for the users endpoint, risking a panic.

"name": llx.StringData(user.DisplayName),
"type": llx.StringData(user.AccountType),
"picture": llx.StringData(user.AvatarUrls.One6X16),
"picture": llx.StringData(user.AvatarURLs.One6X16),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 criticaluser.AvatarURLs is accessed without a nil check here, but the same struct's field is nil-checked in the issues path (line 234). If the v2 library made AvatarURLs a pointer (which the nil check in the issues code suggests), this will panic on users without an avatar.

var picture string
if user.AvatarURLs != nil {
    picture = user.AvatarURLs.One6X16
}

Then use llx.StringData(picture).

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.

3 participants