tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 0015485973e30be5e64cce098b5c57681d334aa3
parent b5fb864e953ebb95f7bb8275ad81511db26b360f
Author: Andrew Halberstadt <ahal@mozilla.com>
Date:   Thu, 23 Oct 2025 14:42:43 +0000

Bug 1990567 - [ci] Catch TaskclusterRestFailure instead of requests.HTTPError, r=taskgraph-reviewers,bhearsum,releng-reviewers

The Taskcluster Python client wraps requests.HTTPError in its own error,
so we need to catch that instead.

Differential Revision: https://phabricator.services.mozilla.com/D269606

Diffstat:
Mtaskcluster/gecko_taskgraph/actions/cancel.py | 6+++---
Mtaskcluster/gecko_taskgraph/actions/cancel_all.py | 6+++---
Mtaskcluster/gecko_taskgraph/actions/gecko_profile.py | 4++--
Mtaskcluster/gecko_taskgraph/actions/release_promotion.py | 6+++---
Mtaskcluster/gecko_taskgraph/actions/util.py | 10+++++-----
Mtaskcluster/gecko_taskgraph/target_tasks.py | 14++++++++------
6 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/taskcluster/gecko_taskgraph/actions/cancel.py b/taskcluster/gecko_taskgraph/actions/cancel.py @@ -5,7 +5,7 @@ import logging -import requests +from taskcluster.exceptions import TaskclusterRestFailure from taskgraph.util.taskcluster import cancel_task from .registry import register_callback_action @@ -25,9 +25,9 @@ def cancel_action(parameters, graph_config, input, task_group_id, task_id): # Note that this is limited by the scopes afforded to generic actions to # only cancel tasks with the level-specific schedulerId. try: - except requests.HTTPError as e: - if e.response.status_code == 409: cancel_task(task_id) + except TaskclusterRestFailure as e: + if e.status_code == 409: # A 409 response indicates that this task is past its deadline. It # cannot be cancelled at this time, but it's also not running # anymore, so we can ignore this error. diff --git a/taskcluster/gecko_taskgraph/actions/cancel_all.py b/taskcluster/gecko_taskgraph/actions/cancel_all.py @@ -7,7 +7,7 @@ import concurrent.futures as futures import logging import os -import requests +from taskcluster.exceptions import TaskclusterRestFailure from taskgraph.util.taskcluster import CONCURRENCY, cancel_task from gecko_taskgraph.util.taskcluster import list_task_group_incomplete_task_ids @@ -32,9 +32,9 @@ def cancel_all_action(parameters, graph_config, input, task_group_id, task_id): def do_cancel_task(task_id): logger.info(f"Cancelling task {task_id}") try: - except requests.HTTPError as e: - if e.response.status_code == 409: cancel_task(task_id) + except TaskclusterRestFailure as e: + if e.status_code == 409: # A 409 response indicates that this task is past its deadline. It # cannot be cancelled at this time, but it's also not running # anymore, so we can ignore this error. diff --git a/taskcluster/gecko_taskgraph/actions/gecko_profile.py b/taskcluster/gecko_taskgraph/actions/gecko_profile.py @@ -6,7 +6,7 @@ import logging import requests -from requests.exceptions import HTTPError +from taskcluster.exceptions import TaskclusterRestFailure from taskgraph.util.taskcluster import get_artifact_from_index, get_task_definition from .registry import register_callback_action @@ -105,7 +105,7 @@ def geckoprofile_action(parameters, graph_config, input, task_group_id, task_id) push_decision_task_id, full_task_graph, label_to_taskid, _ = ( fetch_graph_and_labels(push_params, graph_config) ) - except HTTPError as e: + except TaskclusterRestFailure as e: logger.info(f"Skipping {push} due to missing index artifacts! Error: {e}") continue diff --git a/taskcluster/gecko_taskgraph/actions/release_promotion.py b/taskcluster/gecko_taskgraph/actions/release_promotion.py @@ -6,7 +6,7 @@ import json import os -import requests +from taskcluster.exceptions import TaskclusterRestFailure from taskgraph.parameters import Parameters from taskgraph.taskgraph import TaskGraph from taskgraph.util.taskcluster import get_artifact, list_task_group_incomplete_tasks @@ -312,9 +312,9 @@ def release_promotion_action(parameters, graph_config, input, task_group_id, tas raise Exception( f"task group has unexpected pre-existing incomplete tasks (e.g. {t})" ) - except requests.exceptions.HTTPError as e: + except TaskclusterRestFailure as e: # 404 means the task group doesn't exist yet, and we're fine - if e.response.status_code != 404: + if e.status_code != 404: raise # Build previous_graph_ids from ``previous_graph_ids``, ``revision``, diff --git a/taskcluster/gecko_taskgraph/actions/util.py b/taskcluster/gecko_taskgraph/actions/util.py @@ -12,8 +12,8 @@ from functools import reduce import jsone import requests -from requests.exceptions import HTTPError from slugid import nice as slugid +from taskcluster.exceptions import TaskclusterRestFailure from taskgraph import create from taskgraph.optimize.base import optimize_task_graph from taskgraph.taskgraph import TaskGraph @@ -179,8 +179,8 @@ def fetch_graph_and_labels(parameters, graph_config): label_to_taskid.update(run_label_to_id) for label, task_id in run_label_to_id.items(): label_to_taskids.setdefault(label, []).append(task_id) - except HTTPError as e: - if e.response.status_code != 404: + except TaskclusterRestFailure as e: + if e.status_code != 404: raise logger.debug(f"No label-to-taskid.json found for {task_id}: {e}") @@ -202,8 +202,8 @@ def fetch_graph_and_labels(parameters, graph_config): label_to_taskid.update(run_label_to_id) for label, task_id in run_label_to_id.items(): label_to_taskids.setdefault(label, []).append(task_id) - except HTTPError as e: - if e.response.status_code != 404: + except TaskclusterRestFailure as e: + if e.status_code != 404: raise logger.debug(f"No label-to-taskid.json found for {task_id}: {e}") diff --git a/taskcluster/gecko_taskgraph/target_tasks.py b/taskcluster/gecko_taskgraph/target_tasks.py @@ -9,8 +9,8 @@ import os import re from datetime import datetime, timedelta -import requests from redo import retry +from taskcluster.exceptions import TaskclusterRestFailure from taskgraph import create from taskgraph.target_tasks import filter_for_git_branch, register_target_task from taskgraph.util.attributes import attrmatch @@ -77,7 +77,9 @@ def index_exists(index_path, reason=""): task_id = find_task_id(index_path) print(f"Index {index_path} exists: taskId {task_id}") return True - except KeyError: + except (KeyError, TaskclusterRestFailure) as e: + if isinstance(e, TaskclusterRestFailure) and e.status_code != 404: + raise print(f"Index {index_path} doesn't exist.") return False @@ -1068,8 +1070,8 @@ def target_tasks_searchfox(full_task_graph, parameters, graph_config): try: task = find_task(index_path) print(f"Index {index_path} exists: taskId {task['taskId']}") - except requests.exceptions.HTTPError as e: - if e.response.status_code != 404: + except TaskclusterRestFailure as e: + if e.status_code != 404: raise print(f"Index {index_path} doesn't exist.") else: @@ -1077,8 +1079,8 @@ def target_tasks_searchfox(full_task_graph, parameters, graph_config): taskdef = get_task_definition(task["taskId"]) try: task_graph = get_artifact(task["taskId"], "public/task-graph.json") - except requests.exceptions.HTTPError as e: - if e.response.status_code != 404: + except TaskclusterRestFailure as e: + if e.status_code != 404: raise task_graph = None if task_graph: