refactor(core): migrate issue handling to Arrow IorRaise#30
Open
halotukozak wants to merge 3 commits intomasterfrom
Open
refactor(core): migrate issue handling to Arrow IorRaise#30halotukozak wants to merge 3 commits intomasterfrom
halotukozak wants to merge 3 commits intomasterfrom
Conversation
…arnings Replace SpecValidator.ValidationIssue and string-based error lists with typed Issue.Error/Issue.Warning and Arrow's IorRaise for non-short-circuiting warning accumulation. ParseResult now carries List<Issue.Warning> and a single Issue.Error on failure. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5 tasks
Coverage Report
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors OpenAPI spec parsing/validation to use typed issues (Issue.Error / Issue.Warning) and Arrow’s IorRaise to accumulate warnings without short-circuiting, while returning a single typed error on failure.
Changes:
- Introduces
IssueandWarnings = IorRaise<Nel<Issue.Warning>>plus awarn()helper for warning accumulation. - Rewrites
SpecParser.parseandSpecValidator.validateto use the new typed issue + warning accumulation approach. - Updates Gradle plugin and tests to consume
ParseResultwithwarnings: List<Issue.Warning>andFailure(error: Issue.Error).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| plugin/src/main/kotlin/com/avsystem/justworks/gradle/JustworksGenerateTask.kt | Logs typed warnings and throws on typed parse failure. |
| core/src/main/kotlin/com/avsystem/justworks/core/Issue.kt | Adds typed Issue model, Warnings alias, and warn() helper. |
| core/src/main/kotlin/com/avsystem/justworks/core/parser/SpecParser.kt | Migrates parse pipeline to iorNel warning accumulation and typed error results. |
| core/src/main/kotlin/com/avsystem/justworks/core/parser/SpecValidator.kt | Simplifies validation to if checks that accumulate warnings via warn(). |
| core/src/test/kotlin/com/avsystem/justworks/core/parser/SpecValidatorTest.kt | Updates validator tests to collect warnings via iorNel folding. |
| core/src/test/kotlin/com/avsystem/justworks/core/parser/SpecParserTestBase.kt | Updates failure assertion messaging for typed errors. |
| core/src/test/kotlin/com/avsystem/justworks/core/parser/SpecParserTest.kt | Updates SPEC-03 expectations to warnings and adapts error collection. |
| core/src/test/kotlin/com/avsystem/justworks/core/gen/IntegrationTest.kt | Updates parse failure assertions to typed errors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
core/src/test/kotlin/com/avsystem/justworks/core/parser/SpecParserTest.kt
Show resolved
Hide resolved
plugin/src/main/kotlin/com/avsystem/justworks/gradle/JustworksGenerateTask.kt
Show resolved
Hide resolved
core/src/test/kotlin/com/avsystem/justworks/core/parser/SpecParserTestBase.kt
Show resolved
Hide resolved
…e warn with ensureOrAccumulate / ensureNotNullOrAccumulate
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
core/src/main/kotlin/com/avsystem/justworks/core/parser/SpecValidator.kt
Outdated
Show resolved
Hide resolved
- Change `ensureOrAccumulate` condition to check for empty links instead of non-empty.
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.
Motivation
The previous issue/error model mixed concerns —
SpecValidator.ValidationIssuecarried both errors and warnings in a flat list,SpecParserusedeitherwithParseResult.Failureas the error type (conflating parse-level errors with domain errors), and swagger parser messages were threaded through as raw strings. This made it hard to distinguish fatal errors from recoverable warnings and led to short-circuiting where accumulation was intended.Changes
New domain types (
Issue.kt)Issue.Error— fatal parse/validation failure (single, not accumulated)Issue.Warning— non-fatal observation (accumulated viaIorRaise<Nel<Issue.Warning>>)Warningstypealias for theIorRaisecontextArrow helpers (
ArrowHelpers.kt)ensureOrAccumulate/ensureNotNullOrAccumulate— context-receiver counterparts of Arrow'saccumulate-scoped functions, usable directly inIorRaisecontext without nestingSpecParserparse()now usesiorNel { either { … } }—Ioraccumulates warnings whileEithershort-circuits on the first fatal errorIssue.Warningand accumulated viaIorParseResult.Failurecarries a singleIssue.Errorinstead ofList<String>Raise<ParseResult.Failure>contexts replaced withRaise<Issue.Error>+WarningsSpecValidatorValidationIssuesealed hierarchy — all checks now emitIssue.WarningviaWarningscontextinfo) downgraded to warnings (spec can still be partially processed)ensureOrAccumulate/ensureNotNullOrAccumulatehelpersGradle plugin (
JustworksGenerateTask)Tests
SpecValidatorTest— validates againstList<Issue.Warning>viaiorNelhelperSpecParserTest— SPEC-03 tests updated: missing info is now a warning, not a fatal errorIntegrationTest/SpecParserTestBase— adapted toIssue.Erroron failure pathTest plan
SpecValidatorTestupdated forIorRaise-based APISpecParserTestSPEC-03 tests reflect warning-not-error semanticsaccumulate/raiseshort-circuiting)