mollie / mollie/mollie-api-python

Validate POST/PATCH payloads for required data and correct formatting

Open
#274 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
127
Forks
53
PR merge metrics
No merged PRs in 30d

Description

The current client does not check POST/PATCH payloads at all, they're sent to the API as-is, and the API will validate the contents, possibly returning an error. We could apply basic checks on the payload before sending it to the Mollie API:

  • Are all required keys for the request set?
  • Are all values in the correct data type?
  • Possibly: are values correctly formatted?

Example: for the Create Payment call, we could validate:

  • Are the required keys (amount, description, redirectUrl) in the payload all set?
  • For the amount field: is it a dict, with keys currency and value? Is the currency a non-empty string? Is the value a string, and is it a correctly formatted amount?
  • For the description field: is it a non-empty string?
  • For the redirectUrl field: is it a non-empty string, and formatted as a correct URI?
  • For the optional webhookUrl field: if set in the request, is it a non-empty string and formatted as a correct URI?
  • For the optional locale field: if set in the request, is it a non-empty string?
  • etc ...

All of this could be validated easily using tools like pydantic, marshmallow or jsonschema. With local validation, we could provide the developer with better error messages than the API provides (not checked yet), and we avoid invalid calls to the API.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named; start by tracing the client’s POST/PATCH request paths and reviewing the Create Payment API requirements linked in the issue. Define the validation scope and approach, then cover required and optional fields, types, and formats with clearer local errors before invalid API calls are sent.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.