Validation and errors
Validation runs in stages.
On this page
Overview
Validation runs in stages. Successful definition.Validate() checks declaration shape, not publication readiness. Successful Register additionally creates a staged reference; it also does not mean the content is ready for clients.
| Check | Stage |
|---|---|
| Namespace/path grammar, reserved registration namespace | Definition validation / Register |
Explicit empty display name, stack 1..64 | Definition validation / Register |
| Finite/nonnegative hardness, known tool/category | Definition validation / Register |
Conflicting loot modes, DropsSelf without an item | Definition validation / Register |
| Duplicate IDs within a module scope | Register |
| Collision between modules, legacy/vanilla definitions | Global normalization / final commit recheck |
| Missing icon/terrain texture, geometry, enabled asset closure | Normalization/resource service |
| Unknown block-item/drop reference | Normalization after all registrations |
| Multiple fixed drops | Normalization: current adapter unsupported |
| Unsupported protocol, client hardness range | Per-protocol lowering |
| Runtime ID collision/overflow, stale legacy revision | Host publication preparation/recheck |
| Retained registrar after Load | ErrRegistrationClosed |
An omitted IconRef on a nonplaceable item or TextureRef on a block may pass Validate but fail host normalization. This separates declaration shape from dependency resolution. Likewise, variadic .Drops(...) can contain multiple valid references at the shape-validation stage; the current gameplay adapter rejects multiple outputs.
Error classification
core/content provides four sentinels:
content.ErrRegistrationClosed
content.ErrDuplicateID
content.ErrUnsupportedFeature
content.ErrMissingResource
Use errors.Is, since the host adds context and wraps underlying causes:
if errors.Is(err, content.ErrMissingResource) {
// Enabled assets do not satisfy the declaration.
}
ErrMissingResource also covers malformed/ambiguous references and an unavailable resource service, not only a missing ZIP. ErrUnsupportedFeature identifies host adapter/protocol limitations. There is no universal sentinel for every grammar or unknown-reference error; do not rely on an invented ErrInvalidID or string matching as a stable public contract.
This classification applies to semantic normalization. Direct Resolve* calls, loader/stack failures and structural catalog construction errors can occur earlier and need not wrap ErrMissingResource; preserve the original error and contextual diagnostic.
The usual policy in Load is to return errors immediately. This closes and discards the typed batch. Omitting optional content is a plugin gameplay decision; it must not hide a required block-item or resource failure.
Diagnostics and fixes
| Symptom | Check |
|---|---|
| Unknown item texture | Item atlas alias and enabled stack, not the PNG basename |
| Unknown terrain texture | Terrain atlas, even if the alias exists in the item atlas |
| Ambiguous alias/model | Candidates/provenance and effective higher-priority overrides |
| Duplicate generated item | Manual block-item registration after WithItem |
| Unknown drop item | Whether the referenced item exists before global validation |
| Unsupported protocol | Explicit admin bedrock.protocols, not plugin protocol logic |
| Late registration | Whether the declaration belongs in Load |
Do not fix diagnostics with a fallback to air, another atlas or the latest protocol representation. Missing or unsupported required content must reject startup before admitting players. Reference diagnostics retain the content ID and cause; the host administrator fixes enabled packs/configuration.
Public/normalized/lowering checks and atomicity are covered in definitions_test.go, normalize_test.go, catalog_test.go, lower_test.go, content_publication_test.go.
Player-visible behavior requires separate verification: textures/icons, placement, mining prediction, creative categories, sounds/particles and vanilla palette integrity on a real client. A passing serialization test proves encoding, not every aspect of client rendering.
Documentation source
Snapshot from Pulce 4fc8a1bb. This page is generated from committed Markdown; code examples are preserved unchanged.