refactor(core): convert edit.ts to Result returns#280
Open
galligan wants to merge 1 commit into
Open
Conversation
This was referenced Feb 22, 2026
Contributor
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Replace all 11 throw statements in editWaymark() and its internal helpers with typed Result returns using ValidationError, NotFoundError, and InternalError from @outfitter/contracts. - editWaymark() now returns Promise<WaymarkResult<EditResult>> - Zod .parse() replaced with .safeParse() to avoid exceptions - resolveTarget, resolveRecordContext, assertIdMatches, resolveType, resolveUpdatedRecord, updateIdIndex all return WaymarkResult - Split editWaymark into resolveEditContext + applyEdit to stay under cognitive complexity limit of 15 - Tests updated to unwrap Results via .isOk()/.value - Added 2 new error-path tests (missing file, invalid spec) - Fixed stale @outfitter/contracts@0.2.0 in core workspace WAY-106
37ae890 to
427478a
Compare
8a4de2f to
8eb153a
Compare
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.

Replace all 11 throw statements in editWaymark() and its internal
helpers with typed Result returns using ValidationError, NotFoundError,
and InternalError from @outfitter/contracts.
resolveUpdatedRecord, updateIdIndex all return WaymarkResult
under cognitive complexity limit of 15
WAY-106
Greptile Summary
Successfully converted
editWaymark()from exception-based to Result-based error handling. All 11 throw statements replaced with typed errors (ValidationError,NotFoundError,InternalError).Key changes:
editWaymarkintoresolveEditContext+applyEditto maintain cognitive complexity under 15.parse()with.safeParse()to avoid exceptionsPromise<WaymarkResult<EditResult>>resolveTarget,resolveRecordContext,assertIdMatches,resolveType,resolveUpdatedRecord,updateIdIndex) now returnWaymarkResult@outfitter/contractsfrom 0.2.0 to 0.4.1.isOk()checksConfidence Score: 5/5
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[editWaymark] --> B[resolveEditContext] B --> C{safeParse EditSpec} C -->|Error| D[Return ValidationError] C -->|Success| E[resolveTarget] E -->|Error| D E -->|Success| F[loadFileSnapshot] F -->|Not Found| G[Return NotFoundError] F -->|Success| H[resolveRecordContext] H -->|Error| G H -->|Success| I[assertIdMatches] I -->|Error| D I -->|Success| J[resolveType] J -->|Error| D J -->|Success| K[Return EditContext] A --> L[applyEdit] K --> L L --> M[buildDraftLines] M --> N[applyDraftEdits] N --> O[resolveUpdatedRecord] O -->|Error| P[Return InternalError] O -->|Success| Q{ID exists?} Q -->|Yes| R[updateIdIndex] Q -->|No| S[Return EditResult] R -->|Error| P R -->|Success| SLast reviewed commit: 8eb153a