Enhance address space handling to accept numeric CIDR masks#4734
Enhance address space handling to accept numeric CIDR masks#4734JC-wk wants to merge 43 commits into
Conversation
…e documentation accordingly
Unit Test Results688 tests 688 ✅ 8s ⏱️ Results for commit 3a1ca5f. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Pull request overview
Adds support in the API for requesting auto-assigned address spaces using numeric CIDR prefix lengths (as strings), extending beyond the existing small/medium/large presets while keeping backwards compatibility.
Changes:
- Extend address space allocation logic to accept numeric CIDR masks (string values) and validate allowed ranges.
- Add repository tests for numeric CIDR prefix requests.
- Update workspace authoring documentation and the project changelog to describe the new behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/tre-workspace-authors/authoring-workspace-templates.md | Documents numeric CIDR mask support for address_space_size when requesting additional address spaces. |
| CHANGELOG.md | Records the enhancement in the unreleased changelog. |
| api_app/tests_ma/test_db/test_repositories/test_workpaces_repository.py | Adds tests covering successful numeric CIDR prefix requests. |
| api_app/models/schemas/workspace_template.py | Updates sample schema description text to mention numeric CIDR masks. |
| api_app/db/repositories/workspaces.py | Implements numeric CIDR prefix parsing/validation and routes it into new CIDR allocation. |
Thanks @marrobi
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (2)
api_app/models/schemas/workspace_template.py:26
- The
address_space_sizedescription mentions numeric CIDR masks but doesn't state the accepted mask range (16–29), whileWorkspaceRepository.get_address_space_based_on_sizeenforces that range. Including the range here would make the generated schema clearer and avoid mismatched expectations.
"address_space_size": Property(
type="string",
default="small",
description="This can have a value of small, medium, large, a numeric CIDR mask (e.g. \"24\") or custom. If you specify custom, then you need to specify a VNet address space in 'address_space' (e.g. 10.2.1.0/24)")
},
api_app/models/schemas/workspace_template.py:77
- This example JSON schema description also mentions numeric CIDR masks but doesn't specify the accepted range (16–29), even though the API enforces it. Clarifying the valid range here would make the published schema example more accurate.
"address_space_size": {
"type": "string",
"title": "Address space size",
"description": "This can have a value of small, medium, large, a numeric CIDR mask (e.g. \"24\") or custom. If you specify custom, then you need to specify a VNet address space in 'address_space' (e.g. 10.2.1.0/24)"
},
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (4)
templates/workspaces/base/template_schema.json:52
- The
address_space_sizedescription is ambiguous: it suggests passing a CIDR (e.g. "/24") or an IP range, but the schema actually expects either presets (small/medium/large), a numeric mask length as a string (e.g. "24"), or "custom" with a separateaddress_spaceCIDR. Clarifying this helps prevent users providing values that will be rejected by schema validation.
"description": "Network address size cidr or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.",
templates/workspaces/unrestricted/template_schema.json:44
- The
address_space_sizedescription is ambiguous: it suggests passing a CIDR (e.g. "/24") or an IP range, but the schema actually expects either presets (small/medium/large), a numeric mask length as a string (e.g. "24"), or "custom" with a separateaddress_spaceCIDR. Clarifying this helps prevent users providing values that will be rejected by schema validation.
"description": "Network address size cidr or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.",
templates/workspaces/airlock-import-review/template_schema.json:36
- The
address_space_sizedescription is ambiguous: it suggests passing a CIDR (e.g. "/24") or an IP range, but the schema actually expects either presets (small/medium/large), a numeric mask length as a string (e.g. "24"), or "custom" with a separateaddress_spaceCIDR. Clarifying this helps prevent users providing values that will be rejected by schema validation.
"description": "Network address size cidr or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.",
api_app/db/repositories/workspaces.py:188
- This error message echoes
raw_sizewithout normalization, so inputs with leading/trailing whitespace (e.g. " huge ") will produce a confusing message that includes that whitespace. Using a stripped value makes the error clearer without changing behavior.
raise InvalidInput(f"Invalid 'address_space_size': {raw_size}")
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…crosoft/AzureTRE into jc-wk/address-space-size-cidr
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
docs/tre-workspace-authors/authoring-workspace-templates.md:113
- The new
address_space_sizedocumentation is inaccurate in two ways: (1) it says a numeric mask "16"–"29" asks the system to auto-select an available/25(should be/{mask}), and (2) it says "Workspace templates" may restrict allowed values, but this section is about workspace service templates (and their JSON Schemas).
This parameter accepts the presets `small` (/24), `medium` (/22), `large` (/16), the literal value `custom` together with an explicit `address_space` CIDR (e.g. `10.2.1.0/25`), or (for workspace services) a numeric CIDR mask as a string from "16" to "29" (e.g. `"25"`) to ask the system to auto-select an available `/25`. Workspace templates may further restrict the allowed values via their JSON Schema.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (5)
templates/workspaces/base/template_schema.json:52
- The description says "CIDR value", which can be read as allowing a full CIDR (e.g. "10.2.1.0/25") directly in
address_space_size. In this template schema,address_space_sizeis a prefix length (e.g. "24") or a preset, while full CIDRs are provided viaaddress_spacewhenaddress_space_sizeis "custom". Rewording avoids user confusion.
"description": "Network address size as a CIDR value or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.",
templates/workspaces/unrestricted/template_schema.json:44
- The description says "CIDR value", which can be read as allowing a full CIDR (e.g. "10.2.1.0/25") directly in
address_space_size. In this template schema,address_space_sizeis a prefix length (e.g. "24") or a preset, while full CIDRs are provided viaaddress_spacewhenaddress_space_sizeis "custom". Rewording avoids user confusion.
"description": "Network address size as a CIDR value or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.",
templates/workspaces/airlock-import-review/template_schema.json:36
- The description says "CIDR value", which can be read as allowing a full CIDR (e.g. "10.2.1.0/25") directly in
address_space_size. In this template schema,address_space_sizeis a prefix length (e.g. "24") or a preset, while full CIDRs are provided viaaddress_spacewhenaddress_space_sizeis "custom". Rewording avoids user confusion.
"description": "Network address size as a CIDR value or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.",
api_app/models/schemas/workspace_template.py:25
- This description mentions numeric CIDR masks but doesn't state the enforced range. Since
WorkspaceRepository.get_address_space_based_on_sizerejects values outside 16–29, consider documenting the accepted range here to avoid misleading API consumers.
description="This can have a value of small, medium, large, a numeric CIDR mask (e.g. \"24\") or custom. If you specify custom, then you need to specify a VNet address space in 'address_space' (e.g. 10.2.1.0/24)")
api_app/models/schemas/workspace_template.py:76
- This example JSON schema description mentions numeric CIDR masks but doesn't state the enforced range. Since
WorkspaceRepository.get_address_space_based_on_sizerejects values outside 16–29, consider documenting the accepted range here to avoid misleading API consumers.
"description": "This can have a value of small, medium, large, a numeric CIDR mask (e.g. \"24\") or custom. If you specify custom, then you need to specify a VNet address space in 'address_space' (e.g. 10.2.1.0/24)"
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (5)
templates/workspaces/base/template_schema.json:52
- The
address_space_sizedescription says "CIDR value" and includes a full CIDR example (10.2.1.0/25), but this property is validated as an enum of CIDR mask strings ("16"–"24") plus presets/custom. This wording can mislead users into providing a full CIDR foraddress_space_sizeor expecting /25 to be allowed via the enum.
"description": "Network address size as a CIDR value or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.",
templates/workspaces/unrestricted/template_schema.json:44
- The
address_space_sizedescription says "CIDR value" and includes a full CIDR example (10.2.1.0/25), but this property is validated as an enum of CIDR mask strings ("16"–"24") plus presets/custom. This wording can mislead users into providing a full CIDR foraddress_space_sizeor expecting /25 to be allowed via the enum.
"description": "Network address size as a CIDR value or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.",
templates/workspaces/airlock-import-review/template_schema.json:36
- The
address_space_sizedescription says "CIDR value" and includes a full CIDR example (10.2.1.0/25), but this property is validated as an enum of CIDR mask strings ("16"–"24") plus presets/custom. This wording can mislead users into providing a full CIDR foraddress_space_sizeor expecting /25 to be allowed via the enum.
"description": "Network address size as a CIDR value or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.",
api_app/models/schemas/workspace_template.py:25
- The sample
address_space_sizedescription mentions numeric CIDR masks but doesn't state the accepted range or that the API expects the mask as a string (e.g. "19"), which can lead to inconsistent client implementations.
description="This can have a value of small, medium, large, a numeric CIDR mask (e.g. \"24\") or custom. If you specify custom, then you need to specify a VNet address space in 'address_space' (e.g. 10.2.1.0/24)")
api_app/models/schemas/workspace_template.py:76
- The OpenAPI example schema for
address_space_sizementions numeric CIDR masks but doesn't state the accepted range or that the API expects the mask as a string, which can lead to inconsistent client implementations.
"description": "This can have a value of small, medium, large, a numeric CIDR mask (e.g. \"24\") or custom. If you specify custom, then you need to specify a VNet address space in 'address_space' (e.g. 10.2.1.0/24)"
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (3)
templates/workspaces/base/template_schema.json:52
- The description says "CIDR value", but the enum values are numeric CIDR masks (e.g. "24"), while full CIDR ranges are only valid when using the "custom" option. Tweaking the wording here would avoid confusing users into thinking they can enter "10.0.0.0/24" directly into
address_space_size.
"description": "Network address size as a CIDR value or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.",
templates/workspaces/unrestricted/template_schema.json:44
- Same wording issue as other workspace templates:
address_space_sizeaccepts numeric CIDR masks (e.g. "24"), not a full CIDR range. Clarifying this in the description will prevent users from trying to enter an IP range intoaddress_space_size.
"description": "Network address size as a CIDR value or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.",
templates/workspaces/airlock-import-review/template_schema.json:36
- The schema description currently says "CIDR value", but
address_space_sizeis a numeric CIDR mask (e.g. "24"). Full CIDR ranges belong inaddress_spacewhenaddress_space_sizeis "custom". Updating the description will make that distinction clear.
"description": "Network address size as a CIDR value or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.",
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (5)
templates/workspaces/base/template_schema.json:52
- The description says "CIDR value" but this schema's enum only allows numeric masks "16"–"24" (plus presets). To avoid implying that any CIDR (or "25"–"29") is valid for this workspace template, tighten the wording to match the actual allowed values.
"description": "Network address size as a CIDR value or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.",
templates/workspaces/unrestricted/template_schema.json:44
- The description implies any "CIDR value" is accepted, but the enum only allows numeric masks "16"–"24" (plus presets). Clarify the description so users aren’t misled into thinking "25"–"29" are valid for this workspace template.
"description": "Network address size as a CIDR value or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.",
templates/workspaces/airlock-import-review/template_schema.json:36
- The description suggests a generic "CIDR value", but the enum only permits numeric masks "16"–"24" (plus presets). Update the description to reflect the actual allowed numeric range for this workspace template.
"description": "Network address size as a CIDR value or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.",
api_app/models/schemas/workspace_template.py:26
- This OpenAPI sample description says "CIDR value" without indicating that numeric masks are expected as strings (and that actual allowed values are template-specific). Consider rewording to avoid implying arbitrary CIDR input is valid.
"address_space_size": Property(
type="string",
default="small",
description="Network address size as a CIDR value or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace.")
},
api_app/models/schemas/workspace_template.py:77
- The schema example description uses the ambiguous phrase "CIDR value" even though the feature expects a numeric CIDR mask string (e.g. "23") or presets/custom. Updating this text makes the API docs consistent with the implemented behavior.
"address_space_size": {
"type": "string",
"title": "Address space size",
"description": "Network address size as a CIDR value or (small /24, medium /22, large /16 or custom with an IP range e.g. 10.2.1.0/25) to be used by the workspace."
},

Resolves #4733
What is being addressed
Describe the current behavior you are modifying. Please also remember to update any impacted documentation.
How is this addressed