Skip to content

Commit

Permalink
Source Typeform: fix check connection authenticator loop (#8466)
Browse files Browse the repository at this point in the history
* removed full forms list loop

* better exception return

* Update airbyte-integrations/connectors/source-typeform/source_typeform/source.py

Co-authored-by: Marcos Marx <marcosmarxm@users.noreply.github.com>

* added comments to show bug

* better error handling with empty form list

* rebase

Co-authored-by: Marcos Marx <marcosmarxm@users.noreply.github.com>
Co-authored-by: Marcos Marx <marcosmarxm@gmail.com>
  • Loading branch information
3 people committed Dec 8, 2021
1 parent aa67604 commit 0973b33
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@
- name: Typeform
sourceDefinitionId: e7eff203-90bf-43e5-a240-19ea3056c474
dockerRepository: airbyte/source-typeform
dockerImageTag: 0.1.2
dockerImageTag: 0.1.3
documentationUrl: https://docs.airbyte.io/integrations/sources/typeform
icon: typeform.svg
sourceType: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6354,7 +6354,7 @@
supportsDBT: false
supported_destination_sync_modes:
- "append"
- dockerImage: "airbyte/source-typeform:0.1.2"
- dockerImage: "airbyte/source-typeform:0.1.3"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/sources/typeform"
connectionSpecification:
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-typeform/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.2
LABEL io.airbyte.version=0.1.3
LABEL io.airbyte.name=airbyte/source-typeform
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,30 @@ class SourceTypeform(AbstractSource):
def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, any]:
try:
form_ids = config.get("form_ids", []).copy()
auth = TokenAuthenticator(token=config["token"])
# verify if form inputted by user is valid
for form in TrimForms(authenticator=auth, **config).read_records(sync_mode=SyncMode.full_refresh):
if form.get("id") in form_ids:
form_ids.remove(form.get("id"))
try:
url = f"{TypeformStream.url_base}/me"
auth_headers = {"Authorization": f"Bearer {config['token']}"}
session = requests.get(url, headers=auth_headers)
session.raise_for_status()
except requests.exceptions.BaseHTTPError as e:
return False, f"Cannot authenticate, please verify token. Error: {e}"
if form_ids:
return False, f"Cannot find forms with IDs: {form_ids}. Please make sure they are valid form IDs and try again."
return True, None
for form in form_ids:
try:
url = f"{TypeformStream.url_base}/forms/{form}"
auth_headers = {"Authorization": f"Bearer {config['token']}"}
response = requests.get(url, headers=auth_headers)
response.raise_for_status()
except requests.exceptions.BaseHTTPError as e:
return (
False,
f"Cannot find forms with ID: {form}. Please make sure they are valid form IDs and try again. Error: {e}",
)
return True, None
else:
return True, None

except requests.exceptions.RequestException as e:
return False, e

Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/typeform.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ API rate limits \(2 requests per second\): [https://developer.typeform.com/get-s

| Version | Date | Pull Request | Subject |
| :--- | :--- | :--- | :--- |
| 0.1.3 | 2021-12-07 | [8466](https://github.com/airbytehq/airbyte/pull/8466) | Change Check Connection Function Logic |
| 0.1.2 | 2021-10-11 | [6571](https://github.com/airbytehq/airbyte/pull/6571) | Support pulling data from a select set of forms |
| 0.1.1 | 2021-09-06 | [5799](https://github.com/airbytehq/airbyte/pull/5799) | Add missed choices field to responses schema |
| 0.1.0 | 2021-07-10 | [4541](https://github.com/airbytehq/airbyte/pull/4541) | Initial release for Typeform API supporting Forms and Responses streams |
Expand Down

0 comments on commit 0973b33

Please sign in to comment.