Skip to content

Conversation

@juhoinkinen
Copy link
Member

WIP

@juhoinkinen juhoinkinen added this to the Short term milestone Aug 19, 2025
@juhoinkinen juhoinkinen added maintenance dependencies Pull requests that update a dependency file labels Aug 19, 2025
@sonarqubecloud
Copy link

@juhoinkinen juhoinkinen changed the base branch from main to llms4subjects-natlibfi-germeval2025 August 29, 2025 08:29
@juhoinkinen juhoinkinen changed the base branch from llms4subjects-natlibfi-germeval2025 to main August 29, 2025 08:29
Allows additional metadata fields starting
    with 'metadata_' in the request body while rejecting other fields.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 9, 2025

@juhoinkinen
Copy link
Member Author

In addition to upgrading to Schemathesis 4, this PR currently enables strict_validation in Connexion "to disallow any extra parameters that are not defined in your specification". I think this would be a good feature, because then typos in API requests parameters are noticed at once, not after debugging (with strict validation e.g. using theshold instead of threshold gives 400 Bad request error, without it the extra, nonfunctional parameter is just silently ignored).

However, Annif 1.4 introduced metadata_* parameters to suggest/, suggest_batch/ and learn/ API methods (#867), and to return a 400 error for requests with parameters not starting with metadata_ I made this commit: Add Custom request body validator.

But because of this, Schemathesis 4.7 (correctly) complains:

  | - API rejected schema-compliant request
  | 
  |     Valid data should have been accepted
  |     Expected: 2xx, 401, 403, 404, 409, 5xx
  | 
  | [400] Bad Request:
  | 
  |     `{"type": "about:blank", "title": "Bad Request", "detail": "Extra formData parameter(s) x-schemathesis-additional not in spec", "status": 400}`
  | 
  | Reproduce with: 
  | 
  |     curl -X POST -H 'Content-Type: application/x-www-form-urlencoded' -d 'language=&limit=10&text=&threshold=0&x-schemathesis-additional=' http://localhost/v1/projects/dummy-fi/suggest

Schemathesis should be configurable to ignore this, but I did not manage in that for now.

@osma what do you think about enabling the strict validation and the custom validator? Those could and should be done in another PR than this, if we want start using those.

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

Labels

dependencies Pull requests that update a dependency file maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants