Skip to content

Resolves issue #1748, Adds quota bounds to Org JSON schemas to prevent MongoDB constraint errors.#1750

Merged
david-rocca merged 1 commit intov2.7.5_featurefrom
dr_1748
Apr 17, 2026
Merged

Resolves issue #1748, Adds quota bounds to Org JSON schemas to prevent MongoDB constraint errors.#1750
david-rocca merged 1 commit intov2.7.5_featurefrom
dr_1748

Conversation

@david-rocca
Copy link
Copy Markdown
Collaborator

Closes Issue #1748

Summary

This PR adds maximum bounds checking to hard_quota and soft_quota properties in the CNAOrg.json and SecretariatOrg.json schemas. Previously, unbound quota values bypassed initial validation and instead crashed during Mongoose validation, resulting in a database constraint error and an unhandled 500 status. The schema now correctly intercepts these invalid payloads and returns a 400 Bad Request.

Important Changes

src/middleware/schemas/CNAOrg.json

  • Added "maximum": 100000 to hard_quota and soft_quota.
    src/middleware/schemas/SecretariatOrg.json
  • Added "maximum": 100000 to hard_quota and soft_quota.
    test/integration-tests/registry-org/registryOrgCRUDTest.js
  • Added an integration test simulating a PUT to /registry/org/:short_name with an invalidly high quota (1000000) asserting it fails accurately with a 400 status.

Testing

Steps to manually test updated functionality, if possible

  • 1) Authenticate as a Secretariat user and send a PUT request to /api/registryOrg/{short_name}.
  • 2) Include hard_quota: 1000000 in the request body.
  • 3) Verify that the server responds with a 400 Bad Request and message Parameters were invalid, instead of a 500 Internal Server Error.
  • 4) Run the org integration tests locally: npm run test:integration and verify they pass.

Notes

  • The maximum bound of 100000 corresponds directly with Mongoose's existing configuration CONSTANTS.MONGOOSE_VALIDATION.Org_policies_id_quota_max.

@david-rocca david-rocca changed the base branch from dev to v2.7.5_feature April 16, 2026 14:53
@david-rocca david-rocca merged commit db91a30 into v2.7.5_feature Apr 17, 2026
8 of 9 checks passed
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.

2 participants