Skip to content

fix(host-ports): apply TaskConstraints in TaskCommands (ZD-L1) - #145

Merged
HecFranco merged 1 commit into
mainfrom
fix/zd-l1-task-commands-constraints
Nov 22, 2026
Merged

HecFranco merged 1 commit into
mainfrom
fix/zd-l1-task-commands-constraints

Conversation

@HecFranco

Copy link
Copy Markdown
Contributor

Summary

Target: 2.30.2 (patch). Not to be merged/tagged by the fixer; owner decides. CHANGELOG entry under [Unreleased].

  • ZD-L1 (Low): TaskCommandsInterface only checked the title, link URL length, document title, column name and minutes. TaskCommands now runs the same Validation\TaskConstraints as the page forms (one source of truth) before anything is written:
    • addLink(): linkUrl() (http/https only: refuses javascript:, data: …), linkLabel(), linkExternalId()
    • createTask() / updateTask(): taskTitle(), taskColor() (#rrggbb), at most TAGS_MAX (20) tags, each tagName() (non-string tags refused)
    • addComment(): commentBody(); logTime(): timeNote(); addHostObjectLink(): linkLabel(); addColumn(): columnColor()
    • A refusal is InvalidArgumentException, the port's existing invalid-input type (USAGE: map to 422 at an HTTP edge, as the Task API does). The Task API does not go through TaskCommands and already validates its fields (422), unchanged.
  • ZD-I5 (additive): TaskChangedException::CODE = 'CONFLICT_001'; USAGE tells hosts to send it as X-Conflict-Code with the 409.
  • Validator: new optional last constructor argument ?ValidatorInterface $validator = null (wired @?validator; a standalone Validation::createValidator() otherwise). No BC break; no new translation keys (port exception messages are developer-facing English like the existing ones).

Worker mode (reset false): TaskCommands stays final readonly, the validator is set once in the constructor, no request state. Standard and DDD hosts: same id-based port, no entity in the API.

Tests

  • HostPortsTest::testTheFormsConstraintsAreAppliedBeforeAnyWrite: javascript: and data: links, red; colour on create and update, 21 tags, 65-char / blank / non-string tags, 5001-char comment, 513-char note, 256-char labels, 129-char external id, red; column colour → all refused, nothing stored; the form limits (20 tags, 255/128/5000/512 chars, http://intranet/..., #123) still pass.
  • Conflict test asserts TaskChangedException::CODE.
  • Local (SQLite, PHP 8.4): 3199 tests OK (46 skipped); TaskCommands 100% lines (260/260), TaskChangedException 100%. Overall local 99.49% statements, the gap only in TaskBoardExtension (optional-package branches; main's CI gate is green), so the 100% gate is for CI to confirm.
  • Real databases: tests/Functional/HostPorts on MySQL 8.4 OK (31 tests, 2264 assertions) and PostgreSQL 16 OK (31 tests, 1 skipped).
  • PHPStan: no errors; CS: clean.

🤖 Generated with Claude Code

TaskCommandsInterface only checked titles, URL length and minutes, so a
host passing user input could store javascript:/data: link URLs, free-form
colours, more than 20 tags and over-long comments, notes, labels and
external ids that the page forms refuse. TaskCommands now runs the same
Validation\TaskConstraints before any write and throws
InvalidArgumentException, like its other invalid input. Adds
TaskChangedException::CODE (CONFLICT_001) for host conflict mapping
(ZD-I5).
@HecFranco
HecFranco merged commit f8e6fe3 into main Nov 22, 2026
24 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.

1 participant