Skip to content

feat(skills): throw typed errors from the skill loader - #1129

Merged
kalenkevich merged 1 commit into
google:mainfrom
SHAI-krishna-Dobhal:feat/807-skills-typed-errors
Oct 23, 2026
Merged

kalenkevich merged 1 commit into
google:mainfrom
SHAI-krishna-Dobhal:feat/807-skills-typed-errors

Conversation

@SHAI-krishna-Dobhal

Copy link
Copy Markdown
Contributor

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

2. Or, if no issue exists, describe the change:

Problem:
core/src/skills/loader.ts throws a bare Error for every failure, so callers can't tell a missing SKILL.md from malformed frontmatter or an unsafe zip without string-matching error.message. The typed errors from #583 exist but are unused here.

Solution:
First Stage 2 slice of #807, scoped to core/src/skills/. All 11 bare throws in the loader now use the existing typed errors. Messages are byte-identical; only the class changes.

  • NotFoundError (2): SKILL.md missing from a skill directory or from a zipped skill.
  • InputValidationError (9): frontmatter missing/unclosed/not a mapping, invalid YAML, schema failure, skill name not matching the directory, missing/invalid skill name, dangerous zip entry.
  • The two Invalid YAML in frontmatter rewraps now keep the original error as cause. To allow that, InputValidationError accepts standard ErrorOptions as an optional second argument (backward compatible).
  • @throws JSDoc updated to name the new types.

The Stage 1 inventory proposed a SkillFormatError for these sites. Until new types are agreed on #807, this uses the existing InputValidationError; switching later is a rename.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

npx vitest run core/test/skills core/test/errors: 8 files, 111 passed, 1 skipped (pre-existing skipIf(win32)).
Added: type assertions for InputValidationError / NotFoundError from the loader, a check that the YAML parse error is kept as cause, and an InputValidationError cause test. All existing message assertions pass unchanged. prettier --check, eslint and tsc --noEmit are clean.

Manual End-to-End (E2E) Tests:

N/A. Library-internal error types only; covered by unit tests.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

What a catch block sees changes: the thrown value is now an InputValidationError / NotFoundError (still instanceof Error), and error.name / String(error) show the new class name. Code matching on error.message is unaffected.

@Varun-S10

Copy link
Copy Markdown
Contributor

Hi @SHAI-KrishnaDobhal, Thank you for raising the PR, and thank you for your patience and understanding. We have reproduced the issue, checked the PR changes, and verified that all unit, integration, and build checks are passing.
We are forwarding this to the team for review and merge.
Hi @kalenkevich, Could you please take a look?

@kalenkevich
kalenkevich merged commit d3bf84d into google:main Oct 23, 2026
15 checks passed
@kalenkevich kalenkevich mentioned this pull request Oct 22, 2026
OsamaAnsar added a commit to OsamaAnsar/adk-js that referenced this pull request Oct 26, 2026
Resolve the conflict in core/src/skills/loader.ts with the typed errors
from google#1129: keep the byte order mark and exact --- delimiter parsing, and
throw InputValidationError from the two frontmatter checks. Assert the
error class in the new error-path tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review [Status] The PR/issue is awaiting review from the maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants