From 8fd0e574d2f101aceb982009ba23fc195673556b Mon Sep 17 00:00:00 2001 From: Jack Green Date: Fri, 27 Mar 2026 19:18:09 +0000 Subject: [PATCH] Improve error handling on authentication failure When incorrect credentials are supplied, it's hard to reason this from the error produced: ``` % GITHUB_WORKSPACE=. \ INPUT_FROM=readme.md \ INPUT_TO=1 \ INPUT_CLOUD=hazelcast \ INPUT_USER=user@example.com \ INPUT_TOKEN=incorrect-token \ python3 src/main.py Traceback (most recent call last): File "confluence-markdown-sync/src/main.py", line 47, in 'id': current['id'], KeyError: 'id' ``` Instead, by checking the response we get a _hint_ where the problem might be: ``` requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://hazelcast.atlassian.net/wiki/rest/api/content/1 ``` --- src/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.py b/src/main.py index f8415d9..7c59175 100644 --- a/src/main.py +++ b/src/main.py @@ -33,7 +33,9 @@ if '://' in base_url: # It's a full URL else: # It's a subdomain url = f"https://{base_url}.atlassian.net/wiki/rest/api/content/{envs['to']}" -current = requests.get(url, auth=(envs['user'], envs['token'])).json() +response = requests.get(url, auth=(envs['user'], envs['token'])) +response.raise_for_status() +current = response.json() html = markdown(md, extensions=[GithubFlavoredMarkdownExtension()]) content = {