Skip to content

Commit c9af17d

Browse files
committed
Merge branch 'main' into brian/remove_cursor_and_rfr_from_simple_retriever
2 parents ef0f3f8 + f0443aa commit c9af17d

File tree

13 files changed

+279
-570
lines changed

13 files changed

+279
-570
lines changed

.github/pr-welcome-community.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ As needed or by request, Airbyte Maintainers can execute the following slash com
2727
- `/autofix` - Fixes most formatting and linting issues
2828
- `/poetry-lock` - Updates poetry.lock file
2929
- `/test` - Runs connector tests with the updated CDK
30+
- `/prerelease` - Triggers a prerelease publish with default arguments
3031

3132
If you have any questions, feel free to ask in the PR comments or join our [Slack community](https://airbytehq.slack.com/).

.github/pr-welcome-internal.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Airbyte Maintainers can execute the following slash commands on your PR:
2626
- `/autofix` - Fixes most formatting and linting issues
2727
- `/poetry-lock` - Updates poetry.lock file
2828
- `/test` - Runs connector tests with the updated CDK
29+
- `/prerelease` - Triggers a prerelease publish with default arguments
2930
- `/poe build` - Regenerate git-committed build artifacts, such as the pydantic models which are generated from the manifest JSON schema in YAML.
3031
- `/poe <command>` - Runs any poe command in the CDK environment
3132

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: On-Demand Prerelease
2+
3+
# Minimal permissions for security (addresses GitHub Advanced Security feedback)
4+
permissions:
5+
contents: read
6+
pull-requests: write
7+
issues: write
8+
9+
on:
10+
workflow_dispatch:
11+
inputs:
12+
pr:
13+
description: "PR Number"
14+
type: string
15+
required: false
16+
comment-id:
17+
description: "Comment ID (Optional)"
18+
type: string
19+
required: false
20+
21+
jobs:
22+
prerelease-on-demand:
23+
name: Trigger Prerelease Publish
24+
runs-on: ubuntu-24.04
25+
steps:
26+
- name: Authenticate as GitHub App
27+
uses: actions/create-github-app-token@v2
28+
id: get-app-token
29+
with:
30+
owner: "airbytehq"
31+
repositories: "airbyte-python-cdk"
32+
app-id: ${{ secrets.OCTAVIA_BOT_APP_ID }}
33+
private-key: ${{ secrets.OCTAVIA_BOT_PRIVATE_KEY }}
34+
35+
- name: Create URL to the run output
36+
id: vars
37+
run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT
38+
39+
- name: Check that PR number is provided
40+
if: github.event.inputs.pr == ''
41+
run: |
42+
echo "Error: /prerelease command must be invoked on a pull request, not an issue."
43+
exit 1
44+
45+
- name: Get PR info
46+
id: pr-info
47+
run: |
48+
PR_JSON=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.inputs.pr }})
49+
HEAD_REF=$(echo "$PR_JSON" | jq -r .head.ref)
50+
HEAD_REPO=$(echo "$PR_JSON" | jq -r .head.repo.full_name)
51+
echo "head-ref=${HEAD_REF}" >> $GITHUB_OUTPUT
52+
echo "head-repo=${HEAD_REPO}" >> $GITHUB_OUTPUT
53+
echo "PR branch: ${HEAD_REF} from ${HEAD_REPO}"
54+
env:
55+
GH_TOKEN: ${{ steps.get-app-token.outputs.token }}
56+
57+
- name: Check that PR is from this repository (not a fork)
58+
if: steps.pr-info.outputs.head-repo != github.repository
59+
run: |
60+
echo "Error: /prerelease only works for branches in this repository, not forks."
61+
echo "PR is from: ${{ steps.pr-info.outputs.head-repo }}"
62+
echo "Expected: ${{ github.repository }}"
63+
exit 1
64+
65+
- name: Append comment with job run link
66+
if: github.event.inputs.comment-id
67+
id: first-comment-action
68+
uses: peter-evans/create-or-update-comment@v4
69+
with:
70+
comment-id: ${{ github.event.inputs.comment-id }}
71+
issue-number: ${{ github.event.inputs.pr }}
72+
body: |
73+
> **Prerelease Job Info**
74+
>
75+
> This job triggers the publish workflow with default arguments to create a prerelease.
76+
>
77+
> Prerelease job started... [Check job output.][1]
78+
79+
[1]: ${{ steps.vars.outputs.run-url }}
80+
81+
- name: Trigger publish workflow
82+
id: trigger-publish
83+
uses: the-actions-org/workflow-dispatch@v4
84+
with:
85+
workflow: publish.yml
86+
token: ${{ steps.get-app-token.outputs.token }}
87+
ref: ${{ steps.pr-info.outputs.head-ref }}
88+
wait-for-completion: true
89+
display-workflow-run-url: false
90+
inputs: >-
91+
{
92+
"publish_to_pypi": "true",
93+
"publish_to_dockerhub": "true",
94+
"publish_manifest_server": "false",
95+
"update_connector_builder": "false"
96+
}
97+
98+
- name: Append success comment
99+
if: github.event.inputs.comment-id
100+
uses: peter-evans/create-or-update-comment@v4
101+
with:
102+
comment-id: ${{ steps.first-comment-action.outputs.comment-id }}
103+
reactions: hooray
104+
body: |
105+
> ✅ Prerelease workflow triggered successfully.
106+
>
107+
> View the publish workflow run: ${{ steps.trigger-publish.outputs.workflow-url }}
108+
109+
- name: Append failure comment
110+
if: failure() && github.event.inputs.comment-id
111+
uses: peter-evans/create-or-update-comment@v4
112+
with:
113+
comment-id: ${{ steps.first-comment-action.outputs.comment-id }}
114+
reactions: confused
115+
body: |
116+
> ❌ Failed to trigger prerelease workflow.

.github/workflows/publish.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ on:
2020
Note that this workflow is intended for prereleases. For public-facing stable releases,
2121
please use the GitHub Releases workflow instead:
2222
https://github.com/airbytehq/airbyte-python-cdk/blob/main/docs/RELEASES.md.
23-
For prereleases, please leave the version blank to use the detected version. Alternatively,
24-
you can override the dynamic versioning for special use cases.
23+
For prereleases, you can use the /prerelease slash command in a PR comment to trigger
24+
this workflow with default arguments. Alternatively, you can manually trigger this workflow
25+
and leave the version blank to use the detected version, or override the dynamic versioning
26+
for special use cases.
2527
required: false
2628
publish_to_pypi:
2729
description: "Publish to PyPI. If true, the workflow will publish to PyPI."

.github/workflows/slash_command_dispatch.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
test
3636
poetry-lock
3737
poe
38+
prerelease
3839
3940
# Notes regarding static-args:
4041
# - Slash commands can be invoked from both issues and comments.
@@ -63,6 +64,7 @@ jobs:
6364
- \`/autofix\` - Corrects any linting or formatting issues
6465
- \`/test\` - Runs the test suite
6566
- \`/poetry-lock\` - Re-locks dependencies and updates the poetry.lock file
67+
- \`/prerelease\` - Triggers a prerelease publish with default arguments
6668
- \`/help\` - Shows this help message"
6769
6870
if [[ "${{ github.event.comment.body }}" == "/help" ]]; then

airbyte_cdk/sources/declarative/auth/oauth.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import logging
66
from dataclasses import InitVar, dataclass, field
77
from datetime import datetime, timedelta
8-
from typing import Any, List, Mapping, Optional, Union
8+
from typing import Any, List, Mapping, Optional, Tuple, Union
99

1010
from airbyte_cdk.sources.declarative.auth.declarative_authenticator import DeclarativeAuthenticator
1111
from airbyte_cdk.sources.declarative.interpolation.interpolated_boolean import InterpolatedBoolean
@@ -46,6 +46,9 @@ class DeclarativeOauth2Authenticator(AbstractOauth2Authenticator, DeclarativeAut
4646
refresh_request_headers (Optional[Mapping[str, Any]]): The request headers to send in the refresh request
4747
grant_type: The grant_type to request for access_token. If set to refresh_token, the refresh_token parameter has to be provided
4848
message_repository (MessageRepository): the message repository used to emit logs on HTTP requests
49+
refresh_token_error_status_codes (Tuple[int, ...]): Status codes to identify refresh token errors in response
50+
refresh_token_error_key (str): Key to identify refresh token error in response
51+
refresh_token_error_values (Tuple[str, ...]): List of values to check for exception during token refresh process
4952
"""
5053

5154
config: Mapping[str, Any]
@@ -72,9 +75,16 @@ class DeclarativeOauth2Authenticator(AbstractOauth2Authenticator, DeclarativeAut
7275
message_repository: MessageRepository = NoopMessageRepository()
7376
profile_assertion: Optional[DeclarativeAuthenticator] = None
7477
use_profile_assertion: Optional[Union[InterpolatedBoolean, str, bool]] = False
78+
refresh_token_error_status_codes: Tuple[int, ...] = ()
79+
refresh_token_error_key: str = ""
80+
refresh_token_error_values: Tuple[str, ...] = ()
7581

7682
def __post_init__(self, parameters: Mapping[str, Any]) -> None:
77-
super().__init__()
83+
super().__init__(
84+
refresh_token_error_status_codes=self.refresh_token_error_status_codes,
85+
refresh_token_error_key=self.refresh_token_error_key,
86+
refresh_token_error_values=self.refresh_token_error_values,
87+
)
7888
if self.token_refresh_endpoint is not None:
7989
self._token_refresh_endpoint: Optional[InterpolatedString] = InterpolatedString.create(
8090
self.token_refresh_endpoint, parameters=parameters

airbyte_cdk/sources/declarative/declarative_component_schema.yaml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,28 @@ definitions:
14271427
type: string
14281428
examples:
14291429
- "%Y-%m-%d %H:%M:%S.%f+00:00"
1430+
refresh_token_error_status_codes:
1431+
title: Refresh Token Error Status Codes
1432+
description: Status Codes to Identify refresh token error in response (Refresh Token Error Key and Refresh Token Error Values should be also specified). Responses with one of the error status code and containing an error value will be flagged as a config error
1433+
type: array
1434+
items:
1435+
type: integer
1436+
examples:
1437+
- [400, 500]
1438+
refresh_token_error_key:
1439+
title: Refresh Token Error Key
1440+
description: Key to Identify refresh token error in response (Refresh Token Error Status Codes and Refresh Token Error Values should be also specified).
1441+
type: string
1442+
examples:
1443+
- "error"
1444+
refresh_token_error_values:
1445+
title: Refresh Token Error Values
1446+
description: 'List of values to check for exception during token refresh process. Used to check if the error found in the response matches the key from the Refresh Token Error Key field (e.g. response={"error": "invalid_grant"}). Only responses with one of the error status code and containing an error value will be flagged as a config error'
1447+
type: array
1448+
items:
1449+
type: string
1450+
examples:
1451+
- ["invalid_grant", "invalid_permissions"]
14301452
refresh_token_updater:
14311453
title: Refresh Token Updater
14321454
description: When the refresh token updater is defined, new refresh tokens, access tokens and the access token expiry date are written back from the authentication response to the config object. This is important if the refresh token can only used once.
@@ -1468,7 +1490,7 @@ definitions:
14681490
examples:
14691491
- ["credentials", "token_expiry_date"]
14701492
refresh_token_error_status_codes:
1471-
title: Refresh Token Error Status Codes
1493+
title: (Deprecated - Use the same field on the OAuthAuthenticator level) Refresh Token Error Status Codes
14721494
description: Status Codes to Identify refresh token error in response (Refresh Token Error Key and Refresh Token Error Values should be also specified). Responses with one of the error status code and containing an error value will be flagged as a config error
14731495
type: array
14741496
items:
@@ -1477,14 +1499,14 @@ definitions:
14771499
examples:
14781500
- [400, 500]
14791501
refresh_token_error_key:
1480-
title: Refresh Token Error Key
1502+
title: (Deprecated - Use the same field on the OAuthAuthenticator level) Refresh Token Error Key
14811503
description: Key to Identify refresh token error in response (Refresh Token Error Status Codes and Refresh Token Error Values should be also specified).
14821504
type: string
14831505
default: ""
14841506
examples:
14851507
- "error"
14861508
refresh_token_error_values:
1487-
title: Refresh Token Error Values
1509+
title: (Deprecated - Use the same field on the OAuthAuthenticator level) Refresh Token Error Values
14881510
description: 'List of values to check for exception during token refresh process. Used to check if the error found in the response matches the key from the Refresh Token Error Key field (e.g. response={"error": "invalid_grant"}). Only responses with one of the error status code and containing an error value will be flagged as a config error'
14891511
type: array
14901512
items:

airbyte_cdk/sources/declarative/models/declarative_component_schema.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
2-
31
# generated by datamodel-codegen:
42
# filename: declarative_component_schema.yaml
53

@@ -426,19 +424,19 @@ class RefreshTokenUpdater(BaseModel):
426424
[],
427425
description="Status Codes to Identify refresh token error in response (Refresh Token Error Key and Refresh Token Error Values should be also specified). Responses with one of the error status code and containing an error value will be flagged as a config error",
428426
examples=[[400, 500]],
429-
title="Refresh Token Error Status Codes",
427+
title="(Deprecated - Use the same field on the OAuthAuthenticator level) Refresh Token Error Status Codes",
430428
)
431429
refresh_token_error_key: Optional[str] = Field(
432430
"",
433431
description="Key to Identify refresh token error in response (Refresh Token Error Status Codes and Refresh Token Error Values should be also specified).",
434432
examples=["error"],
435-
title="Refresh Token Error Key",
433+
title="(Deprecated - Use the same field on the OAuthAuthenticator level) Refresh Token Error Key",
436434
)
437435
refresh_token_error_values: Optional[List[str]] = Field(
438436
[],
439437
description='List of values to check for exception during token refresh process. Used to check if the error found in the response matches the key from the Refresh Token Error Key field (e.g. response={"error": "invalid_grant"}). Only responses with one of the error status code and containing an error value will be flagged as a config error',
440438
examples=[["invalid_grant", "invalid_permissions"]],
441-
title="Refresh Token Error Values",
439+
title="(Deprecated - Use the same field on the OAuthAuthenticator level) Refresh Token Error Values",
442440
)
443441

444442

@@ -1900,6 +1898,24 @@ class OAuthAuthenticator(BaseModel):
19001898
examples=["%Y-%m-%d %H:%M:%S.%f+00:00"],
19011899
title="Token Expiry Date Format",
19021900
)
1901+
refresh_token_error_status_codes: Optional[List[int]] = Field(
1902+
None,
1903+
description="Status Codes to Identify refresh token error in response (Refresh Token Error Key and Refresh Token Error Values should be also specified). Responses with one of the error status code and containing an error value will be flagged as a config error",
1904+
examples=[[400, 500]],
1905+
title="Refresh Token Error Status Codes",
1906+
)
1907+
refresh_token_error_key: Optional[str] = Field(
1908+
None,
1909+
description="Key to Identify refresh token error in response (Refresh Token Error Status Codes and Refresh Token Error Values should be also specified).",
1910+
examples=["error"],
1911+
title="Refresh Token Error Key",
1912+
)
1913+
refresh_token_error_values: Optional[List[str]] = Field(
1914+
None,
1915+
description='List of values to check for exception during token refresh process. Used to check if the error found in the response matches the key from the Refresh Token Error Key field (e.g. response={"error": "invalid_grant"}). Only responses with one of the error status code and containing an error value will be flagged as a config error',
1916+
examples=[["invalid_grant", "invalid_permissions"]],
1917+
title="Refresh Token Error Values",
1918+
)
19031919
refresh_token_updater: Optional[RefreshTokenUpdater] = Field(
19041920
None,
19051921
description="When the refresh token updater is defined, new refresh tokens, access tokens and the access token expiry date are written back from the authentication response to the config object. This is important if the refresh token can only used once.",

0 commit comments

Comments
 (0)