Skip to content

Migrate error-string vectors to native expectedError (#489) - #499

Merged
Seth Juarez (sethjuarez) merged 2 commits into
mainfrom
sethjuarez/error-vectors-expectederror
Aug 23, 2026
Merged

Migrate error-string vectors to native expectedError (#489)#499
Seth Juarez (sethjuarez) merged 2 commits into
mainfrom
sethjuarez/error-vectors-expectederror

Conversation

@sethjuarez

Copy link
Copy Markdown
Member

Closes #489.

Replaces the bespoke {"error": ...} vector payloads and fuzzy substring matchers with the typra harness's native expectedError mechanism across all seven runtimes.

What changed

The six load.tsp error vectors now carry a canonical {kind, [field]} expectedError payload:

  • env_var_not_set
  • file_reference
  • file_not_found
  • invalid_frontmatter
  • invalid_template
  • missing_required_input (+ field)

Each runtime's adapter maps its typed load/validation error onto the canonical kind by exception type — never by matching message text:

  • PythonPromptyLoadError.kind is already canonical (reference adapter).
  • Go / Rust / TypeScript / C# — typed load-error classes expose the kind; adapters map type → canonical kind and drop the fuzzy matchers. (New typed error surfaces: errors.py, errors.ts, PromptyLoadException.cs.)
  • JavaVectorAdapters + LoadVectorsTest map LoadException/InvokerException to the canonical payload; assertErrorMatches deleted from SpecVectors.
  • Swift — the prompty-model conformance adapter throws VectorError with the canonical payload; the SDK LoadVectorTests maps LoadError/InvokerError cases to canonical kinds. The SDK loader collapses a bare-string template into .invalidModel (a single Agent.load schema step), which the test asserts directly as the SDK's classification of invalid_template.

Removes the fuzzy error matchers (_err, assertErrorMatches, expectErrorMatches, and equivalents) in favour of type-based mapping.

Verification — all seven runtimes green

Runtime Result
Python 180 conformance passed
Go ok (conformance)
Rust 721 passed
TypeScript 180 passed
C# 204 (conformance + loader)
Java conformance + LoadVectors green
Swift 285 (prompty-model) + 192 (SDK) passed

Replace the bespoke `{"error": ...}` payloads and fuzzy substring matchers
with the typra harness's native `expectedError` mechanism across all seven
runtimes.

The six load.tsp error vectors now carry a canonical `{kind, [field]}`
expectedError payload: env_var_not_set, file_reference, file_not_found,
invalid_frontmatter, invalid_template, and missing_required_input (+field).
Each runtime's adapter maps its typed load/validation error onto the
canonical kind by exception TYPE -- never by matching message text:

- Python: PromptyLoadError.kind is already canonical (reference adapter).
- Go / Rust / TypeScript / C#: typed load-error classes expose the kind;
  adapters map type -> canonical kind and drop the fuzzy matchers.
- Java: VectorAdapters + LoadVectorsTest map LoadException/InvokerException
  to the canonical payload; assertErrorMatches deleted from SpecVectors.
- Swift: the prompty-model conformance adapter throws VectorError with the
  canonical payload; the SDK LoadVectorTests maps LoadError/InvokerError
  cases to canonical kinds. The SDK loader collapses a bare-string template
  into .invalidModel (one Agent.load schema step), which the test asserts
  directly as the SDK's classification of invalid_template.

Removes the fuzzy error matchers (Python _err, Java assertErrorMatches,
Swift expectErrorMatches, and equivalents) in favour of type-based mapping.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6194cf76-47f5-40ba-b7ee-aed2df52146c
Comment on lines +76 to +81
catch (Exception ex)
{
throw new PromptyLoadException(
"invalid_frontmatter",
$"Invalid frontmatter in '{fullPath}': {ex.Message}");
}
Comment on lines +285 to +295
foreach (var prop in agent.Inputs)
{
if (string.IsNullOrEmpty(prop.Name))
continue;
if (provided.ContainsKey(prop.Name))
continue;
if (prop.Default is not null || prop.Example is not null)
continue;
if (prop.Required == true)
return prop.Name;
}
}
if (expObj is not null && expObj.ContainsKey("error") && input.ContainsKey("inputs") && input.ContainsKey("frontmatter"))
// --- input-validation vectors: BOTH a top-level `inputs` map AND `frontmatter` ---
if (input.ContainsKey("inputs") && input.ContainsKey("frontmatter"))
}
if (expObj is not null && expObj.ContainsKey("error") && input.ContainsKey("inputs") && input.ContainsKey("frontmatter"))
// --- input-validation vectors: BOTH a top-level `inputs` map AND `frontmatter` ---
if (input.ContainsKey("inputs") && input.ContainsKey("frontmatter"))
{
return ErrorResult(exc, expected);
}
loaded = PromptyLoader.Load(Path.Combine(SpecFixtures, fixtureVal.GetValue<string>()));
The #489 expectedError migration left a type-cast in buildAgent that
exceeded Prettier's line width. Reflow it so runtime/typescript
format:check passes; no behavior change (TS suite green: 1675 core).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6194cf76-47f5-40ba-b7ee-aed2df52146c
@sethjuarez
Seth Juarez (sethjuarez) merged commit 4643392 into main Aug 23, 2026
35 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.

test(vectors): migrate bespoke error-string vectors to native expectedError + per-runtime normalizers

1 participant