QTZPOC-20

QTZPOC-20: Simplify base64 decoding error handling and improve run name derivation test specificity
This commit is contained in:
2026-09-04 11:15:48 -03:00
parent bde614e2a6
commit 7b2e90a9f9
2 changed files with 3 additions and 4 deletions

View File

@@ -16,7 +16,6 @@ used as a metric label or written to the import record.
from __future__ import annotations
import base64
import binascii
from typing import Final
from cryptography.exceptions import InvalidTag
@@ -55,7 +54,7 @@ def load_envelope_key(raw_key: str | None) -> bytes:
raise EnvelopeError('the import password key is not configured')
try:
key = base64.b64decode(raw_key, validate=True)
except (binascii.Error, ValueError) as error:
except ValueError as error:
raise EnvelopeError('the import password key is not valid base64') from error
if len(key) != KEY_SIZE:
raise EnvelopeError(f'the import password key must be {KEY_SIZE} bytes')
@@ -80,7 +79,7 @@ def decrypt_password_envelope(envelope: str, key: bytes) -> str:
raise EnvelopeError('the import request carries no password envelope')
try:
payload = base64.b64decode(envelope, validate=True)
except (binascii.Error, ValueError) as error:
except ValueError as error:
raise EnvelopeError('the password envelope is not valid base64') from error
if len(payload) < MIN_ENVELOPE_SIZE:
raise EnvelopeError('the password envelope is too short to hold a nonce and a tag')