Skip to content

[Server] Mask internal errors consistently during list authorization #2177

Open

Description

@timothyw553

Describe the bug

ResultFilter.filter() masks unexpected exceptions, but rethrows 5xx BaseExceptions with their original messages. Each source must therefore sanitize its own error messages. The registered-model parent lookup already does this and has regression coverage.

This tracks the broader follow-up requested in the review of #2078.

To Reproduce

A focused unit-test scenario:

  1. Make a list-item authorizer throw BaseException(INTERNAL, "test-only backend detail").
  2. Run the item through ResultFilter.filter().
  3. The outer catch rethrows that message unchanged.

Expected behavior

Handle internal error masking in the outer list-filter catch, so every list path has the same protection. Preserve error codes and original causes, and keep actionable OPA UNAVAILABLE messages. Permission denials and existing 4xx filtering should keep their current behavior.

Add focused regression coverage for direct and SpEL-wrapped failures. Once the outer catch handles masking, remove the redundant registered-model lookup wrapper.

System

Server at dc45fb6c; applies to both Casbin and OPA.

Additional context

Current outer catch. Follow-up work is separate from #2078.

Activity

  1. greglum commented on Nov 27, 2026

    @greglum

    take

  2. greglum commented on Nov 27, 2026

    @greglum

    I have a fix implemented and tested locally, and want to confirm two behavior details before opening the PR:

    1. Masking scope: ResultFilter.filter() masks every non-UNAVAILABLE server-side BaseException (INTERNAL, DATA_LOSS, UNIMPLEMENTED, COMMIT_STATE_UNKNOWN) with "Failed to authorize list items" while keeping the original ErrorCode and cause. The removed REGISTERED_MODEL parent-lookup wrapper previously masked those codes too, so masking only INTERNAL would newly expose them.
    2. UNAVAILABLE passthrough: removing the REGISTERED_MODEL wrapper lets ErrorCode.UNAVAILABLE pass through on the list path. In current code KeyMapper catalog/schema lookups wrap database errors as INTERNAL, so only OpaAuthorizer and JCasbinAuthorizer throw UNAVAILABLE on list authorization.

    Does this match what you want, or would you prefer narrowing masking to ErrorCode.INTERNAL only?

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