Skip to content

feat(oci/skills): add sentinel errors for packager failure classification#95

Merged
samuv merged 3 commits intomainfrom
improve-build
Apr 27, 2026
Merged

feat(oci/skills): add sentinel errors for packager failure classification#95
samuv merged 3 commits intomainfrom
improve-build

Conversation

@samuv
Copy link
Copy Markdown
Contributor

@samuv samuv commented Apr 27, 2026

Summary

  • Adds six exported sentinel errors in oci/skills (ErrInvalidSkillDir, ErrSkillMDMissing, ErrInvalidFrontmatter, ErrTooManyFiles, ErrSkillTooLarge, ErrInvalidSkillFile) so callers can classify packaging failures with errors.Is instead of brittle string matching
  • Wraps every failure site in validateSkillDir, readSkillDirectory, parseFrontmatter, collectSkillFiles, and validateSkillFile with %w to the matching sentinel; original human-readable messages are preserved so existing string-based assertions and downstream UX strings keep working
  • Scope is intentionally limited to packager errors — the tar.go / gzip.go / registry.go size and structure limits remain internal/transport concerns and can be promoted to sentinels later if a consumer needs to disambiguate them. No httperr mapping is added inside the package; HTTP semantics belong in the consumer's handler layer

Test plan

  • task passes (lint + tests green, race detector enabled)
  • TestPackager_Package_SentinelErrors: table-driven errors.Is coverage for missing/invalid dir, path traversal, missing SKILL.md, the four frontmatter failure modes (no opening delim, no closing delim, oversize, invalid YAML), missing name, and symlinked file/directory
  • TestCollectSkillFiles_ExceedsMaxFiles extended with assert.ErrorIs(t, err, ErrTooManyFiles)
  • TestCollectSkillFiles_ExceedsMaxSize: streams just over maxSkillTotalSize to disk and asserts ErrSkillTooLarge
  • All pre-existing assert.Contains(t, err.Error(), ...) assertions kept untouched and still pass — message text is unchanged

@samuv samuv self-assigned this Apr 27, 2026
@samuv samuv merged commit 7b2f381 into main Apr 27, 2026
5 checks passed
@samuv samuv deleted the improve-build branch April 27, 2026 15:03
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.

2 participants