Skip to content

gate-49 does not recognise catch (\\Throwable), which is strictly broader than the nine it tracks #204

Closed

Description

@rubenvdlinde

gate-49 accepts a catch only for one of nine named domain exceptions:

TRACKED = [DoesNotExistException, MultipleObjectsReturnedException, NotFoundException,
           PermissionException, ValidationException, ForbiddenException,
           CustomValidationException, AppendOnlyException, ArchivalImmutableException]

catch (\Throwable $e) matches none of them — yet it catches all nine, plus everything else. So the broadest possible translation is reported as no translation at all.

Hit on ConductionNL/hermiq#162: SettingsController::index/create/load were flagged with no handling, I added catch (\Throwable) to each with a translated JSON response and a log, and the gate still reports "3 controller method(s) missing try/catch or @throws".

Why it matters beyond a false positive

The finding pushes authors toward the narrower fix. Catching only DoesNotExistException where the real risk is "the service blew up for a reason I have not enumerated" leaves the uncaught path — a framework 500 with a stack trace — exactly where it was. For index() that trace reaches a non-admin, since the method is #[NoAdminRequired].

Suggested

Treat catch (\Throwable) and catch (\Exception) as satisfying the gate. They are supersets of the tracked list; a gate that rejects the stronger guarantee teaches people to write the weaker one.

Worked around for now with the documented opt-out ([hydra-gate-controller-exception-translation exclude] …), which is the right escape hatch but should not be needed for the broadest correct handler.

Related: #203 — gate-55 and gate-60 encode two different icon registries for the same widget field, with no opt-out at all.

Activity

  1. rubenvdlinde commented on Aug 7, 2026

    @rubenvdlinde
    ContributorAuthor

    Fixed in #211 (merged 2026-08-07).

    Each fix ships with a control proving the gate can still fail:

    • gate-49 now matches \Throwable/\Exception; no-catch and an unrelated class still do not
    • _optout_text reads the PR body and the author's head SHA; verified that plain git log -1 does NOT see a tag written behind a merge commit while the helper does

    Note for #204 specifically: the fix is inside the PINNED hydra-gates package, so it reaches a repo only when its hydra-gates-ref moves to a tag containing it. Tag + consumer sweep to follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions