Skip to content

fix: don't call MetadataApplier.fail() after apply() throws#176

Open
ivanauth wants to merge 1 commit into
authzed:mainfrom
ivanauth:fix/issue-117-bearertoken-error-handling
Open

fix: don't call MetadataApplier.fail() after apply() throws#176
ivanauth wants to merge 1 commit into
authzed:mainfrom
ivanauth:fix/issue-117-bearertoken-error-handling

Conversation

@ivanauth

@ivanauth ivanauth commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Closes #117.

If applier.apply() throws, the applier is already finalized, so the subsequent applier.fail() raised "apply() or fail() already called" and masked the original exception. This moves apply() outside the try block so its exception propagates as-is, and narrows the catch (Throwable) to catch (RuntimeException) (per @tstirrat15's note about not catching all throwables).

BearerToken caught Throwable around the whole metadata application and
called applier.fail() on any error. When applier.apply() itself threw,
the applier was already finalized, so fail() raised "apply() or fail()
already called" and hid the original exception. Only failures while
building the metadata now trigger fail(), and the catch is narrowed
from Throwable to RuntimeException.

Signed-off-by: ivanauth <ivan@authzed.com>
@ivanauth
ivanauth requested a review from a team as a code owner July 16, 2026 18:27
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.

BearerToken error handling fail

1 participant