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

Raise AuthException on 401 response #26

Merged
merged 1 commit into from
Aug 2, 2018

Conversation

nick-mccoy
Copy link
Contributor

The tap was not catching 401 responses (Auth Error). This changes the tap so it looks for a 401 and raises an exception when it happens.

@nick-mccoy
Copy link
Contributor Author

Tested on a problematic connection, and things look good:

$ /home/vagrant/.virtualenvs/tap-github/bin/tap-github --config /tmp/tap_config.json --properties /tmp/properties.json --catalog /tmp/catalog.json --state /tmp/tap_state.json
{"stream": "assignees", "type": "SCHEMA", "key_properties": ["id"], "schema": {"properties": {"url": {"type": ["null", "string"], "inclusion": "available", "selected": true}, "type": {"type": ["null", "string"], "inclusion": "available", "selected": true}, "id": {"type":
["null", "integer"], "inclusion": "automatic", "selected": false}, "login": {"type": ["null", "string"], "inclusion": "available", "selected": true}}, "additionalProperties": false, "selected": true, "type": ["null", "object"]}}
INFO METRIC: {"type": "timer", "value": 0.18870115280151367, "tags": {"endpoint": "assignees", "status": "failed"}, "metric": "http_request_duration"}
INFO METRIC: {"type": "counter", "value": 0, "tags": {"endpoint": "assignees"}, "metric": "record_count"}
CRITICAL {"message":"Bad credentials","documentation_url":"https://developer.github.com/v3"}
Traceback (most recent call last):
  File "/home/vagrant/.virtualenvs/tap-github/bin/tap-github", line 9, in <module>
    load_entry_point('tap-github==1.0.0', 'console_scripts', 'tap-github')()
  File "/home/vagrant/.virtualenvs/tap-github/lib/python3.4/site-packages/singer/utils.py", line 192, in wrapped
    return fnc(*args, **kwargs)
  File "/opt/code/tap-github/tap_github.py", line 390, in main
    do_sync(args.config, args.state, catalog)
  File "/opt/code/tap-github/tap_github.py", line 363, in do_sync
    state = sync_func(stream_schema, config, state, mdata)
  File "/opt/code/tap-github/tap_github.py", line 180, in get_all_assignees
    'https://api.github.com/repos/{}/assignees'.format(repo_path)
  File "/opt/code/tap-github/tap_github.py", line 41, in authed_get_all_pages
    r = authed_get(source, url, headers)
  File "/opt/code/tap-github/tap_github.py", line 34, in authed_get
    raise AuthException(resp.text)
tap_github.AuthException: {"message":"Bad credentials","documentation_url":"https://developer.github.com/v3"}
(tap-github)

@nick-mccoy
Copy link
Contributor Author

Should address #24 and #25

@nick-mccoy nick-mccoy merged commit 23be408 into master Aug 2, 2018
@nick-mccoy nick-mccoy deleted the raise_auth_exception_on_401 branch August 2, 2018 13:43
AJWurts pushed a commit to villagelabsco/tap-github that referenced this pull request Oct 24, 2024
…n_401

Raise AuthException on 401 response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant