Skip to content

Add better errors for filter failures#2739

Merged
emmiegit merged 6 commits intodevelopfrom
filter-error
Mar 7, 2026
Merged

Add better errors for filter failures#2739
emmiegit merged 6 commits intodevelopfrom
filter-error

Conversation

@emmiegit
Copy link
Member

@emmiegit emmiegit commented Mar 7, 2026

While working on #2736, I noticed that the errors produced by our new error system could be improved. This is something that we will periodically bump in to, as we enhance error messages with additional context while we work on them.

This change adds the regex of the failed filter(s) to the logging, but also more broadly exposes the contextual error data to the full error result.

With the exn crate, we have a layered error system which shows the call trace that this error took to fail. Our ErrorType also has associated contextual data, but all except for the top-most layer is not preserved.

This changes that, instead having a list of the associated error data under the field extra.

New call trace:

[1001] method 'user_create' failed, at src/api.rs:378:5
|
|-> [1008] failed to create user, at src/endpoints/user.rs:37:10
|
|-> [1008] failed to create user 'some-person' with email 'foobar@example.net', at src/services/user/service.rs:86:13
|
|-> [1008] user failed email filter, at src/services/user/service.rs:867:14
|
|-> [5100] filter failure for field 'email', at src/services/filter/matcher.rs:80:9

JSON:

{
    "code": 5100,
    "message": "The request violates a configured content filter",
    "data": {
        "call_trace": "[... see above ...]",
        "code_trace": [
            1001,
            1008,
            1008,
            1008,
            5100
        ],
        "extra": [
            null,
            null,
            null,
            null,
            {
                "failed": [
                    {
                        "description": "Cannot join using example.net emails (example)",
                        "filter_id": 4,
                        "regex": "(?i)^.*@example\\.net$"
                    }
                ],
                "field": "email",
                "value": "foobar@example.net"
            }
        ]
    }
}

This shows which filter(s) failed, the regex that triggered it, and the listed description value associated with the filter.

@emmiegit emmiegit requested a review from Zokhoi March 7, 2026 05:21
@emmiegit emmiegit self-assigned this Mar 7, 2026
@codecov
Copy link

codecov bot commented Mar 7, 2026

Codecov Report

❌ Patch coverage is 0% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 2.28%. Comparing base (dfc6c81) to head (ea4f4ea).
⚠️ Report is 9 commits behind head on develop.

Files with missing lines Patch % Lines
deepwell/src/error/error_type.rs 0.00% 14 Missing ⚠️
deepwell/src/error/convert.rs 0.00% 8 Missing ⚠️
deepwell/src/services/filter/service.rs 0.00% 6 Missing ⚠️
deepwell/src/services/filter/matcher.rs 0.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #2739      +/-   ##
==========================================
- Coverage     2.29%   2.28%   -0.01%     
==========================================
  Files          171     171              
  Lines        10287   10309      +22     
==========================================
  Hits           236     236              
- Misses       10051   10073      +22     
Files with missing lines Coverage Δ
deepwell/src/services/filter/matcher.rs 0.00% <0.00%> (ø)
deepwell/src/services/filter/service.rs 0.00% <0.00%> (ø)
deepwell/src/error/convert.rs 0.00% <0.00%> (ø)
deepwell/src/error/error_type.rs 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@emmiegit emmiegit merged commit 499e9cd into develop Mar 7, 2026
9 checks passed
@emmiegit emmiegit deleted the filter-error branch March 7, 2026 06:37
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.

2 participants