Skip to content

[stable33] fix(validation): harden unified files contract#7445

Merged
vitormattos merged 81 commits intostable33from
backport/7442/stable33
Apr 7, 2026
Merged

[stable33] fix(validation): harden unified files contract#7445
vitormattos merged 81 commits intostable33from
backport/7442/stable33

Conversation

@backportbot-libresign
Copy link
Copy Markdown

@backportbot-libresign backportbot-libresign bot commented Apr 7, 2026

Backport of #7442

Warning, This backport's changes differ from the original and might be incomplete ⚠️

Todo

  • Review and resolve any conflicts
  • Amend HEAD commit to remove the line stating to skip CI

Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…ction

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…edFile

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…lidatedFile

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…gress

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…y url

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…llection

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…act guards

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
… validation

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…tries

- Replace array_map with foreach to properly filter invalid signer entries
- Validate signRequestId as required field (must be integer or numeric string)
- Type-cast fields explicitly: displayName, email, statusText to string; status to int
- Skip empty array returns for non-array inputs
- Preserve identifyMethods when present
- Ensures all returned summaries comply with OpenAPI schema contract

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
- Test rejection of array inputs (prevent numeric keys conversion)
- Test filtering of non-string values
- Test empty object and null handling
- Verify proper handling of mixed string/non-string values
- Covers edge cases like empty strings and various input types

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…vice

- Extract normalizeRouteRecord from Validation.vue to dedicated service
- Add explicit array rejection to prevent numeric keys (e.g., {'0': 'a', '1': 'b'})
- Type-cast string values explicitly for type safety
- Drop non-string values with logging
- Improve contract enforcement for route params/query handling

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
- Remove local normalizeRouteRecord function from Validation.vue
- Import and use normalizeRouteRecord from services/routeNormalization
- Improves maintainability and enables dedicated testing
- No behavioral change, preserves all existing functionality

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
- Test acceptance of requested_by.displayName as null (missing profile info)
- Test type validation still works (rejects non-string and missing)
- Covers edge case where requester profile information is unavailable

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
- Update isRequestedBy() to allow displayName as null
- Aligns with OpenAPI contract that allows null for missing profile info
- Prevents rejection of valid API payloads when requester info is unavailable

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…thod

Extracted the signRequestId type casting and validation logic from
mapSignerDetailsToSummary() into a dedicated private method
extractValidSignRequestId(). This improves code readability by:

- Removing inline validation comment (code is now self-documenting)
- Centralizing validation logic in a named method that clearly explains
  the operation (extracting a valid ID or returning null)
- Making the validation testable and reusable
- Simplifying the main loop by delegating validation concern

The method name clearly conveys intent without requiring explanatory
comments. All 178 FileServiceTest assertions pass with no regressions.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Extracted validation and transformation logic into self-documenting helper
functions:

- isValidRecordInput(): Type guard clearly stating 'is object and not array'
- shouldRejectAsArray(): Explains the design decision to reject arrays
- buildStringOnlyRecord(): Separates string-filtering logic with clear intent

Benefits:
- Removed inline conditional logic that required explanatory comments
- Each function name now conveys purpose without additional documentation
- Improved testability of individual concerns
- Simplified main normalizeRouteRecord() function body

All 9 routeNormalization tests pass with no regressions. Full test suite
validates: 2317 tests across 171 files. TypeScript type checking clean.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
The method name extractValidSignRequestId() and its return type ?int

already express the full contract. The comment was paraphrasing both

without adding new information.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos vitormattos force-pushed the backport/7442/stable33 branch from 5ed59b0 to fe84fea Compare April 7, 2026 01:33
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos vitormattos marked this pull request as ready for review April 7, 2026 01:52
@vitormattos vitormattos merged commit eda1ccd into stable33 Apr 7, 2026
65 checks passed
@vitormattos vitormattos deleted the backport/7442/stable33 branch April 7, 2026 01:53
@github-project-automation github-project-automation bot moved this from 0. Needs triage to 4. to release in Roadmap Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 4. to release

Development

Successfully merging this pull request may close these issues.

1 participant