dosubot[bot] commented on issue #8708:
URL: 
https://github.com/apache/incubator-devlake/issues/8708#issuecomment-3882618999

   <!-- Answer -->
   The Bitbucket PR extraction failure is caused by Go's default time.Time 
parsing, which doesn't handle microsecond precision timestamps returned by 
Bitbucket Cloud (e.g., `2025-12-01T12:34:56.123456Z`). The extractor currently 
unmarshals the `created_on` and `updated_on` fields directly into time.Time, 
leading to time.ParseError when microseconds are present.
   
   To fix this, update the BitbucketApiPullRequest struct to use the existing 
`common.Iso8601Time` type for these fields instead of time.Time. The 
`Iso8601Time` helper provides flexible ISO8601 parsing and can be easily 
extended to support microseconds by adding a matcher/format for six-digit 
fractional seconds (or by falling back to `time.RFC3339Nano`) 
[source](https://github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/backend/core/models/common/iso8601time.go#L53-L189).
   
   In summary: replace
   ```go
   BitbucketCreatedAt time.Time `json:"created_on"`
   BitbucketUpdatedAt time.Time `json:"updated_on"`
   ```
   with
   ```go
   BitbucketCreatedAt *common.Iso8601Time `json:"created_on"`
   BitbucketUpdatedAt *common.Iso8601Time `json:"updated_on"`
   ```
   and update downstream usage to call `.ToNullableTime()` or `.ToTime()` as 
needed. This will make the extractor robust to all ISO8601 timestamp variants 
Bitbucket emits, including those with microseconds 
[source](https://github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/backend/plugins/bitbucket/tasks/pr_extractor.go#L40-L163).
   
   If you encounter any timestamp formats not currently handled, you can add a 
new regex/format pair to the `DateTimeFormats` list in `iso8601time.go` for 
full coverage.
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
   
   ---
   <sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/859bbb1b-cd97-48c1-9fdb-994e102b26ea?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/859bbb1b-cd97-48c1-9fdb-994e102b26ea?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/859bbb1b-cd97-48c1-9fdb-994e102b26ea?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/859bbb1b-cd97-48c1-9fdb-994e102b26ea?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/859bbb1b-cd97-48c1-9fdb-994e102b26ea?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/859bbb1b-cd97-48c1-9fdb-994e102b26ea?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/859bbb1b-cd97-48c1-9fdb-994e102b26ea?feedback_type=other)</sup>
   
   [![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/b4e8e847-d479-4541-83a8-d88d83fea5c9/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20Bitbucket%20PR%20extraction%20failure%20is%20caused%20by%20Go%27s%20default%20time.Time%20parsing%2C%20which%20doesn%27t%20handle%20microsecond%20precision%20timestamps%20returned%20by%20Bitbucket%20Cloud%20%28e.g.%2C%20%602025-12-01T12%3A34%3A56.123456Z%60%29.%20The%20extractor%20currently%20unmarshals%20the%20%60created_on%60%20and%20%60updated_on%60%20fields%20directly%20into%20time.Time%2C%20leading%20to%20time.ParseError%20when%20microseconds%20are%20present.%0A%0ATo%20fix%20this%2C%20update%20the%20BitbucketApiPullRequest%20struct%20to%20use%20the%20existing%20%60common.Iso8601Time%60%20type%20for%20these%20fields%20instead%20of%20time.Time.%20The%20%60Iso8601Time%60%20helper%20provides%20flexible%20ISO8601%20parsing%20and%20can%20be%20
 
easily%20extended%20to%20support%20microseconds%20by%20adding%20a%20matcher/format%20for%20six-digit%20fractional%20seconds%20%28or%20by%20falling%20back%20to%20%60time.RFC3339Nano%60%29%20%5Bsource%5D%28https%3A//github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/backend/core/models/common/iso8601time.go%23L53-L189%29.%0A%0AIn%20summary%3A%20replace%0A%60%60%60go%0ABitbucketCreatedAt%20time.Time%20%60json%3A%22created_on%22%60%0ABitbucketUpdatedAt%20time.Time%20%60json%3A%22updated_on%22%60%0A%60%60%60%0Awith%0A%60%60%60go%0ABitbucketCreatedAt%20%2Acommon.Iso8601Time%20%60json%3A%22created_on%22%60%0ABitbucketUpdatedAt%20%2Acommon.Iso8601Time%20%60json%3A%22updated_on%22%60%0A%60%60%60%0Aand%20update%20downstream%20usage%20to%20call%20%60.ToNullableTime%28%29%60%20or%20%60.ToTime%28%29%60%20as%20needed.%20This%20will%20make%20the%20extractor%20robust%20to%20all%20ISO8601%20timestamp%20variants%20Bitbucket%20emits%2C%20including%20those%20with%20micros
 
econds%20%5Bsource%5D%28https%3A//github.com/apache/incubator-devlake/blob/2c15ad880dce830c6512fa58039527cbf4745b8b/backend/plugins/bitbucket/tasks/pr_extractor.go%23L40-L163%29.%0A%0AIf%20you%20encounter%20any%20timestamp%20formats%20not%20currently%20handled%2C%20you%20can%20add%20a%20new%20regex/format%20pair%20to%20the%20%60DateTimeFormats%60%20list%20in%20%60iso8601time.go%60%20for%20full%20coverage.)&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/incubator-devlake/issues/8708)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to