This is an automated email from the ASF dual-hosted git repository.

klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new d7d5fa6e3 fix(bitbucket): handle microsecond precision timestamps in 
PR extractor (#8828)
d7d5fa6e3 is described below

commit d7d5fa6e30087f80ada36edbeb4ffe1a99910efc
Author: Vincenzo <[email protected]>
AuthorDate: Sat Apr 18 04:57:19 2026 +0200

    fix(bitbucket): handle microsecond precision timestamps in PR extractor 
(#8828)
    
    Bitbucket Cloud returns timestamps with 6-digit fractional seconds
    (e.g. 2025-09-15T08:53:36.337932+00:00). Changed BitbucketCreatedAt/
    BitbucketUpdatedAt from time.Time to *common.Iso8601Time and added
    microsecond format to DateTimeFormats.
    
    Fixes #8708
    
    Co-authored-by: Vincenzo Baldi <[email protected]>
---
 backend/core/models/common/iso8601time.go       |  4 ++++
 backend/core/models/common/iso8601time_test.go  | 12 ++++++++++++
 backend/plugins/bitbucket/tasks/pr_extractor.go |  9 ++++-----
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/backend/core/models/common/iso8601time.go 
b/backend/core/models/common/iso8601time.go
index 8b49de208..a0570d009 100644
--- a/backend/core/models/common/iso8601time.go
+++ b/backend/core/models/common/iso8601time.go
@@ -56,6 +56,10 @@ func init() {
                        Matcher: regexp.MustCompile(`[+-][\d]{4}$`),
                        Format:  "2006-01-02T15:04:05-0700",
                },
+               {
+                       Matcher: 
regexp.MustCompile(`[\d]{6}[+-][\d]{2}:[\d]{2}$`),
+                       Format:  "2006-01-02T15:04:05.000000-07:00",
+               },
                {
                        Matcher: 
regexp.MustCompile(`[\d]{3}[+-][\d]{2}:[\d]{2}$`),
                        Format:  "2006-01-02T15:04:05.000-07:00",
diff --git a/backend/core/models/common/iso8601time_test.go 
b/backend/core/models/common/iso8601time_test.go
index b984a6632..4307345da 100644
--- a/backend/core/models/common/iso8601time_test.go
+++ b/backend/core/models/common/iso8601time_test.go
@@ -145,6 +145,18 @@ func TestConvertStringToTime(t *testing.T) {
                        output: time.Date(2023, 3, 1, 0, 0, 0, 0, time.UTC),
                        err:    nil,
                },
+               {
+                       name:   "Valid time string with milliseconds",
+                       input:  "2025-09-15T08:53:36.337+00:00",
+                       output: time.Date(2025, 9, 15, 8, 53, 36, 337000000, 
time.UTC),
+                       err:    nil,
+               },
+               {
+                       name:   "Valid time string with microseconds (Bitbucket 
Cloud format)",
+                       input:  "2025-09-15T08:53:36.337932+00:00",
+                       output: time.Date(2025, 9, 15, 8, 53, 36, 337932000, 
time.UTC),
+                       err:    nil,
+               },
                {
                        name:   "Invalid time string",
                        input:  "invalid",
diff --git a/backend/plugins/bitbucket/tasks/pr_extractor.go 
b/backend/plugins/bitbucket/tasks/pr_extractor.go
index 5edb75e28..a551927b7 100644
--- a/backend/plugins/bitbucket/tasks/pr_extractor.go
+++ b/backend/plugins/bitbucket/tasks/pr_extractor.go
@@ -19,7 +19,6 @@ package tasks
 
 import (
        "encoding/json"
-       "time"
 
        "github.com/apache/incubator-devlake/core/errors"
        "github.com/apache/incubator-devlake/core/models/common"
@@ -57,8 +56,8 @@ type BitbucketApiPullRequest struct {
        } `json:"links"`
        ClosedBy           *BitbucketAccountResponse `json:"closed_by"`
        Author             *BitbucketAccountResponse `json:"author"`
-       BitbucketCreatedAt time.Time                 `json:"created_on"`
-       BitbucketUpdatedAt time.Time                 `json:"updated_on"`
+       BitbucketCreatedAt *common.Iso8601Time       `json:"created_on"`
+       BitbucketUpdatedAt *common.Iso8601Time       `json:"updated_on"`
        BaseRef            *struct {
                Branch struct {
                        Name string `json:"name"`
@@ -174,8 +173,8 @@ func convertBitbucketPullRequest(pull 
*BitbucketApiPullRequest, connId uint64, r
                Url:                pull.Links.Html.Href,
                Type:               pull.Type,
                CommentCount:       pull.CommentCount,
-               BitbucketCreatedAt: pull.BitbucketCreatedAt,
-               BitbucketUpdatedAt: pull.BitbucketUpdatedAt,
+               BitbucketCreatedAt: pull.BitbucketCreatedAt.ToTime(),
+               BitbucketUpdatedAt: pull.BitbucketUpdatedAt.ToTime(),
        }
        if pull.BaseRef != nil {
                if pull.BaseRef.Repo != nil {

Reply via email to