Skip to content

Add pydantic Field requirements to API model attributes#928

Open
Chennamma-Hotkar wants to merge 2 commits into
repository-service-tuf:mainfrom
Chennamma-Hotkar:add-attribute-requirements
Open

Add pydantic Field requirements to API model attributes#928
Chennamma-Hotkar wants to merge 2 commits into
repository-service-tuf:mainfrom
Chennamma-Hotkar:add-attribute-requirements

Conversation

@Chennamma-Hotkar

@Chennamma-Hotkar Chennamma-Hotkar commented Apr 9, 2026

Copy link
Copy Markdown

Description

Adds pydantic Field() constraints to model attributes that previously accepted any integer without validation, as described in #520.

Model Field Constraint Rationale
TUFSignedDelegationsRoles threshold ge=1 TUF spec: ≥1 signature required
TUFSignedDelegationsSuccinctRoles threshold ge=1 Same
TUFSignedRoles threshold ge=1 Same
TUFSignedMetaFile version ge=1 TUF spec: versions start at 1
TUFSigned version ge=1 Same
ArtifactInfo length ge=0 Cannot be negative
BootstrapPayload timeout gt=0 Must be positive

Tests: 13 new unit tests, 99 total pass, tox -e lint clean.

Docs: Regenerated docs/swagger.json.

Signed-off-by: Chennamma Hotkar <channuhotkar@gmail.com>
@MVrachev

Copy link
Copy Markdown
Member

Linting is failing, have a look at the failed pipeline at the bottom of the pr.

@Chennamma-Hotkar

Copy link
Copy Markdown
Author

Thanks for the review @MVrachev! I see the linting failure — some lines exceeded 79 characters due to the description parameter in Field(). I'll fix this by keeping the Field constraints minimal (without descriptions) and push an update shortly.

Signed-off-by: Chennamma Hotkar <channuhotkar@gmail.com>
@Chennamma-Hotkar

Copy link
Copy Markdown
Author

@MVrachev I've pushed a fix — removed Field descriptions to stay within the 79-char line limit, and all lint checks (flake8, isort, black, bandit) pass locally via tox -e lint. Please re-approve the workflow when you get a chance.

@kairoaraujo

Copy link
Copy Markdown
Member

Hi @Chennamma-Hotkar, could you please solve the conflicts?

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