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

[TT-7129] Fix setting global_size_limit not enabling RequestSizeLimitMiddleware #3979

Conversation

PatrickTaibel
Copy link
Contributor

Description

Fix EnabledForSpec in RequestSizeLimitMiddleware for API global limits without size limits in extended_paths.

Related Issue

#3977

Motivation and Context

Makes the RequestSizeLimitMiddleware usable when only API global limits are specified.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring or add test (improvements in base code or adds test coverage to functionality)

Checklist

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side). If pulling from your own
    fork, don't request your master!
  • Make sure you are making a pull request against the master branch (left side). Also, you should start
    your branch off our latest master.
  • My change requires a change to the documentation.
    • If you've changed APIs, describe what needs to be updated in the documentation.
    • If new config option added, ensure that it can be set via ENV variable
  • I have updated the documentation accordingly.
  • Modules and vendor dependencies have been updated; run go mod tidy && go mod vendor
  • When updating library version must provide reason/explanation for this update.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • Check your code additions will not fail linting checks:
    • go fmt -s
    • go vet

@buger
Copy link
Member

buger commented Apr 5, 2022

Nice one!

Keen to add a small test for it?

It can look like this:

func TestValidateJSONSchema(t *testing.T) {
	ts := StartTest(nil)
	defer ts.Close()

	ts.Gw.BuildAndLoadAPI(func(spec *APISpec) {
		UpdateAPIVersion(spec, "v1", func(v *apidef.VersionInfo) {
			v.GlobalSizeLimit = 1
		})
	})

	ts.Run(t, []test.TestCase{
		{Method: "POST", Path: "/sample/", Data: "foobar", Code: http.StatusBadRequest},
	}...)
}

@PatrickTaibel
Copy link
Contributor Author

I've added a small test for this. Thank you very much for the pretty much finished test snippet!

@titpetric titpetric self-requested a review April 21, 2022 20:16
@titpetric
Copy link
Contributor

Everything LGTM, please rebase and check the test failures.

@PatrickTaibel PatrickTaibel force-pushed the pr/fix-request-size-limit-mw branch from 8219774 to 1111195 Compare April 22, 2022 16:55
@PatrickTaibel
Copy link
Contributor Author

I've rebased the branch onto the current master.
The previous test run seems to have failed on test --- FAIL: TestEnforcedTimeout (4.27s). As far as I can tell, this has nothing to do with the changes in this PR.

@titpetric
Copy link
Contributor

I believe the tests on master have been resolved. Can I ask you for the hopefully last rebase? The teams are improving the test case failures, so your best case at merging this soon is unfortunately rebasing until tests pass 😬

@PatrickTaibel PatrickTaibel force-pushed the pr/fix-request-size-limit-mw branch from 1111195 to 47b0dd1 Compare April 26, 2022 12:54
@PatrickTaibel PatrickTaibel force-pushed the pr/fix-request-size-limit-mw branch from 47b0dd1 to 1cb0272 Compare May 24, 2022 13:06
@PatrickTaibel PatrickTaibel force-pushed the pr/fix-request-size-limit-mw branch from 1cb0272 to 6fd80f3 Compare July 29, 2022 08:04
@lghiur lghiur changed the title Fix setting global_size_limit not enabling RequestSizeLimitMiddleware [TT-7129[ Fix setting global_size_limit not enabling RequestSizeLimitMiddleware Jan 10, 2023
@lghiur lghiur changed the title [TT-7129[ Fix setting global_size_limit not enabling RequestSizeLimitMiddleware [TT-7129] Fix setting global_size_limit not enabling RequestSizeLimitMiddleware Jan 10, 2023
titpetric added a commit that referenced this pull request Apr 18, 2023
@titpetric
Copy link
Contributor

I've cherry-picked this over #4967 - your contribution will be included in the 5.1 release. Thank you 🏆

@titpetric titpetric closed this May 11, 2023
tykbot bot pushed a commit that referenced this pull request May 11, 2023
https://tyktech.atlassian.net/browse/TT-7129

Closes #2887 #3979

---------

Co-authored-by: Patrick Taibel <[email protected]>

(cherry picked from commit 19e3137)
tykbot bot pushed a commit that referenced this pull request May 11, 2023
https://tyktech.atlassian.net/browse/TT-7129

Closes #2887 #3979

---------

Co-authored-by: Patrick Taibel <[email protected]>

(cherry picked from commit 19e3137)
buger added a commit that referenced this pull request May 11, 2023
buger added a commit that referenced this pull request May 11, 2023
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.

3 participants