Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC 7807 Compliance #217

Merged
merged 7 commits into from
Oct 6, 2023
Merged

RFC 7807 Compliance #217

merged 7 commits into from
Oct 6, 2023

Conversation

jujaga
Copy link
Member

@jujaga jujaga commented Sep 30, 2023

Description

This PR standardizes how we emit errors to be RFC 7807 compliant, implements a thin validation middleware, standardizes problem handling, and various other minor fixes.

  • 6329d2f Bugfix certain problem throws triggering unhandledRejection crashes
  • bd5362b Refactor Problem handling to throw instead of sending
  • c6d4a80 Revert lib-storage queueSize back to default of 4
  • 8d72173 Ensure authentication happens first before validation
  • 4cf7a1d Drop express-validation library
  • e991f13 Implement new thin validation middleware
  • 52f2b69 Ensure problem repsonses are RFC 7807 compliant

SHOWCASE-3192

Types of changes

Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Documentation (non-breaking change with enhancements to documentation)
Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the CONTRIBUTING doc
  • I have checked that unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Signed-off-by: Jeremy Ho <jujaga@gmail.com>
In order to be RFC 7807 compliant, we need to abandon the
express-validation library as it is too inflexible for our needs. This
middleware steps in to replace that functionality while minimizing impact
to the existing Joi validation codebase.

Signed-off-by: Jeremy Ho <jujaga@gmail.com>
We switch over to using our validation library as it allows us to be
RFC 7807 compliant and also affords us the ability to report all validation
issues instead of just the first one encountered.

Signed-off-by: Jeremy Ho <jujaga@gmail.com>
Signed-off-by: Jeremy Ho <jujaga@gmail.com>
We found that artificially restricting the queueSize adversely impacts
general network throughput of a filestream to S3. Rolling back to Amazon
defaults appears to improve performance without significantly impacting
the memory footprint.

Signed-off-by: Jeremy Ho <jujaga@gmail.com>
In order to standardize how we deal with 400 and 500 class HTTP responses,
we now always throw a Problem error instead of short circuiting with the
send method. Instead, we now depend on the top level app error handler to
capture and render the Problem. This ensures that we only have one pattern
for problem emission. Other minor various unit tests are also updated.

Signed-off-by: Jeremy Ho <jujaga@gmail.com>
@jujaga jujaga added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request dependencies Pull requests that update a dependency file labels Sep 30, 2023
@jujaga jujaga self-assigned this Sep 30, 2023
@codeclimate
Copy link

codeclimate bot commented Sep 30, 2023

Code Climate has analyzed commit 6329d2f and detected 8 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 2
Duplication 6

The test coverage on the diff in this pull request is 84.4% (50% is the threshold).

This pull request will bring the total coverage in the repository to 64.7% (0.2% change).

View more on Code Climate.

@github-actions
Copy link

Coverage Report

Totals Coverage
Statements: 58% ( 2645 / 4560 )
Methods: 47.98% ( 297 / 619 )
Lines: 64.71% ( 1590 / 2457 )
Branches: 51.08% ( 758 / 1484 )

Express 4.x still doesn't have native detection for middleware that throws.
To mitigate, we do their recommended approach of passing in the Problem
to the next callback instead of throwing where applicable.

Signed-off-by: Jeremy Ho <jujaga@gmail.com>
@TimCsaky TimCsaky merged commit 64b9918 into master Oct 6, 2023
12 checks passed
@TimCsaky TimCsaky deleted the feature/exceptions branch October 6, 2023 16:48
TimCsaky added a commit that referenced this pull request Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants