Make incident status optional in create validation#358
Open
jbrooksuk wants to merge 1 commit into
Open
Conversation
The CreateIncidentRequestData validation rules marked `status` as `required`, but the field is optional everywhere else: the constructor defaults it to null, the `incidents.status` column is nullable, and UpdateIncidentRequestData treats it as optional. Incidents created without a status are a valid state (rendered as "reported"). With the workbench's `validation_strategy: Always` and spatie/laravel-data structure caching shared across parallel test workers, the `required` rule could intermittently apply to status-less payloads, failing CreateIncidentTest with "The status field is required." in CI. Aligns the rule with the rest of the codebase by making status nullable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The nightly test run started failing intermittently (run 27315738081) with:
at the two tests that create an incident without a status (
CreateIncidentTest.php:17and:99). It reproduced only under the full parallel suite, not in isolation.Root cause
CreateIncidentRequestData::rules()markedstatusasrequired, butstatusis optional everywhere else:null(?IncidentStatusEnum $status = null)incidents.statuscolumn is nullable (2023_08_21_..._make_incident_columns_nullable)UpdateIncidentRequestDatatreats it as optionalThe workbench config sets
validation_strategy: Always, sofrom()validates on every call, and spatie/laravel-data's structure cache is shared across the 10 parallel test workers via the file store. Once thestatus => requiredrule was resolved/cached from a status-bearing payload, it could be applied to the status-less unit-test payloads — surfacing the failure intermittently depending on worker assignment and ordering.Fix
Make
statusnullableinstead ofrequired, aligning the create rules with the constructor, the column, and the update request. Status-less incident creation now validates deterministically.Verification
Full suite green in parallel on both dependency sets:
--prefer-lowest(spatie/laravel-data 4.11): 408 passed--prefer-stable(spatie/laravel-data 4.23): 408 passed🤖 Generated with Claude Code