Skip to content

Commit 216bda4

Browse files
committed
fix(shared): recurse into Filter issues and protect omission suffix from truncation
- collectSchemaDiagnosticIssues now recurses into Filter.issue when the inner issue is not a bare InvalidValue, matching Effect's own toDefaultIssues behavior. This preserves nested field paths instead of showing generic root-level 'Invalid value' messages. - formatSchemaError now truncates the formatted issues part separately, reserving space for the omission suffix so '... and N more issue(s)' is never silently dropped by the length cap.
1 parent 034068f commit 216bda4

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

packages/shared/src/schemaJson.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ function collectSchemaDiagnosticIssues(
7878
switch (issue._tag) {
7979
case "Encoding":
8080
return collectSchemaDiagnosticIssues(issue.issue, path, diagnostics);
81+
case "Filter":
82+
if (issue.issue._tag !== "InvalidValue") {
83+
return collectSchemaDiagnosticIssues(issue.issue, path, diagnostics);
84+
}
85+
break;
8186
case "Pointer":
8287
return collectSchemaDiagnosticIssues(issue.issue, [...path, ...issue.path], diagnostics);
8388
case "Composite":
@@ -157,11 +162,11 @@ export const formatSchemaError = (cause: Cause.Cause<Schema.SchemaError>) => {
157162

158163
const omittedIssueCount = issueCount - issues.length;
159164
const formatted = issues.map(formatDiagnosticIssue).join("\n");
160-
const withOmittedCount =
161-
omittedIssueCount === 0
162-
? formatted
163-
: `${formatted}\n... and ${omittedIssueCount} more issue(s)`;
164-
return truncateDiagnostic(withOmittedCount, MAX_SCHEMA_DIAGNOSTIC_LENGTH);
165+
if (omittedIssueCount === 0) {
166+
return truncateDiagnostic(formatted, MAX_SCHEMA_DIAGNOSTIC_LENGTH);
167+
}
168+
const suffix = `\n... and ${omittedIssueCount} more issue(s)`;
169+
return truncateDiagnostic(formatted, MAX_SCHEMA_DIAGNOSTIC_LENGTH - suffix.length) + suffix;
165170
};
166171

167172
/**

0 commit comments

Comments
 (0)