Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(source-jira): use unix time as milliseconds when filtering the cursor field via jql #48395

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ryanahall
Copy link

@ryanahall ryanahall commented Nov 7, 2024

…s due to timezone conversions

What

According to https://support.atlassian.com/jira-software-cloud/docs/jql-fields/#Updated, date times are relative to the current configured timezone. In some cases (i.e. using a personal access token), the currently configured timezone may not be UTC.

When streams use the jira advanced search api and request records using JQL (https://support.atlassian.com/jira-service-management-cloud/docs/use-advanced-search-with-jira-query-language-jql/), this cursor value is formatted without a timezone as seen below:

        compare_date = self.get_starting_point(stream_state)
        if compare_date:
            compare_date = compare_date.strftime("%Y/%m/%d %H:%M")
            return f"{self.cursor_field} >= '{compare_date}'"

In our case, we've noticed that the issues stream for jira returns records with an updated field value (the cursor field) formatted as UTC. Subsequent syncs will use this value, truncate the timezone (which is UTC), and pass it along to jira. When the session has a timezone that has a negative UTC offset, this results in data being skipped. When the session has a timezone with a positive UTC offset, data is unnecessarily emitted.

For example, an initial sync may return it's final issue record with a cursor of 2024-11-06 12:00:00.000+0000 representing noon UTC time. The next sync will query using jql with the following filter: updated >= '2024-11-06 12:00:00'. If the session's timezone is America/Los_Angeles, then this filters records with an updated time that is greater than or equal to 2024-11-06 20:00:00.000+0000 due to the UTC offset. Any records updated between 12 and 20 UTC time are skipped.

How

According to https://support.atlassian.com/jira-software-cloud/docs/jql-fields/#Updated, the jira jql api supports epoch values when filtering against the updated field amongst other timestamp fields. Notably, they mention that if you omit the quote-marks, the number you supply will be interpreted as milliseconds after epoch (1970-1-1).

This change modifies jql_compare_date to append a filter of {self.cursor_field} >= {compare_date_epoch}, where compare_date_epoch represents the epoch value in milliseconds of the current datetime value.

Review guide

User Impact

If the session is already configured with a UTC timezone, there's no change. For sessions with a timezone offset from UTC, they should see more consistent record updates for incremental streams.

Can this PR be safely reverted and rolled back?

  • YES 💚
  • NO ❌

Copy link

vercel bot commented Nov 7, 2024

@ryanahall is attempting to deploy a commit to the Airbyte Growth Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Nov 7, 2024

CLA assistant check
All committers have signed the CLA.

@ryanahall ryanahall changed the title Use unix epoch when querying with jql to avoid inconsistent timestamp… fix(source-jira): use unix epoch when querying with jql to avoid inconsistent timestamp… Nov 7, 2024
@ryanahall ryanahall changed the title fix(source-jira): use unix epoch when querying with jql to avoid inconsistent timestamp… fix(source-jira): use unit time as milliseconds when filtering the cursor field via jql Nov 7, 2024
@ryanahall ryanahall changed the title fix(source-jira): use unit time as milliseconds when filtering the cursor field via jql fix(source-jira): use unix time as milliseconds when filtering the cursor field via jql Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation community connectors/source/jira
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants