Pulcedocs

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.

CheckStage
Namespace/path grammar, reserved registration namespaceDefinition validation / Register
Explicit empty display name, stack 1..64Definition validation / Register
Finite/nonnegative hardness, known tool/categoryDefinition validation / Register
Conflicting loot modes, DropsSelf without an itemDefinition validation / Register
Duplicate IDs within a module scopeRegister
Collision between modules, legacy/vanilla definitionsGlobal normalization / final commit recheck
Missing icon/terrain texture, geometry, enabled asset closureNormalization/resource service
Unknown block-item/drop referenceNormalization after all registrations
Multiple fixed dropsNormalization: current adapter unsupported
Unsupported protocol, client hardness rangePer-protocol lowering
Runtime ID collision/overflow, stale legacy revisionHost publication preparation/recheck
Retained registrar after LoadErrRegistrationClosed

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

SymptomCheck
Unknown item textureItem atlas alias and enabled stack, not the PNG basename
Unknown terrain textureTerrain atlas, even if the alias exists in the item atlas
Ambiguous alias/modelCandidates/provenance and effective higher-priority overrides
Duplicate generated itemManual block-item registration after WithItem
Unknown drop itemWhether the referenced item exists before global validation
Unsupported protocolExplicit admin bedrock.protocols, not plugin protocol logic
Late registrationWhether 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.