Bazooka

Latest version: v1.3.0

Safety actively analyzes 723217 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

1.3.0

**Feature: Enhanced Error Handling for Authentication/Authorization Failures**

This release introduces improved error differentiation for HTTP 401 (Unauthorized) responses to streamline error handling in authentication/authorization workflows.

**Key Changes:**
- **New Exception Class:** Added the `UnauthorizedError` class, inheriting from `ClientError`, to explicitly represent HTTP 401 errors.
- **Error Mapping Update:** The `wrap_to_bazooka_exception` handler now maps generic `HTTPError` instances with status code 401 to the dedicated `UnauthorizedError`, enabling downstream systems to reliably detect and respond to authentication/authorization failures.

**Impact:**
- Clearer distinction of unauthorized errors improves debugging and programmatic handling (e.g., triggering re-authentication flows or customized logging).
- Aligns with best practices for API error management by providing granular exception types.

1.2.0

**New Features & Improvements:**
- **Added Custom Exception Classes:** Introduced `BadRequestError` and `ForbiddenError`, both inheriting from `ClientError`, to provide more granular error handling for specific HTTP status scenarios.
- **Enhanced Error Mapping:** Updated the `wrap_to_bazooka_exception` handler to automatically:
- Raise `BadRequestError` when an HTTP 400 (BAD_REQUEST) response is detected.
- Raise `ForbiddenError` when an HTTP 403 (FORBIDDEN) response is encountered.

**Impact:**
These changes improve error management by distinguishing between client-side errors (400 and 403 statuses), allowing developers to handle these cases more explicitly and streamline debugging workflows.

1.1.0

REST URI Utilities Module

We're excited to introduce a new core module to streamline REST API client development in the `bazooka` package!

**What's New:**
- **Added `common.py` module** — A dedicated utilities module for REST URI handling.
- **`force_last_slash` function**: Ensures consistent path normalization by automatically appending a trailing slash to URIs when needed.
- **`RESTClientMixIn` class**: A reusable mix-in class providing foundational methods for RESTful URI construction:
- **`_build_resource_uri()`**: Dynamically constructs full resource URIs from path components, ideal for individual resource endpoints.
- **`_build_collection_uri()`**: Specialized method for building URIs targeting collection resources, ensuring consistent formatting.

**Use Case:**
These utilities simplify URI management for API clients, reduce code duplication, and enforce standardization across REST interactions.

1.0.0

None

Links

Releases

Has known vulnerabilities

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.