Skip to content

SiteKit Error Codes

Use SiteKitError and SiteKitErrorCode from @alneas/sitekit/errors. The class also appears in the root export. It requires no React provider or CSS. Content-file and build APIs remain Node-only; the error class itself performs no I/O.

Carries a stable code, corrective hint and public documentation link while remaining an ordinary Error.

import type { SiteKitErrorCode } from '@alneas/sitekit/errors';
declare class SiteKitError extends Error {
readonly name: "SiteKitError";
readonly code: SiteKitErrorCode;
readonly hint: string;
readonly docs: string;
constructor(code: SiteKitErrorCode, message: string, options?: ErrorOptions);
}
Parameter Type Required Description
code SiteKitErrorCode Yes One of the identifiers below; selects its hint and documentation anchor.
message string Yes Failure context without credentials or sensitive payloads.
options.cause unknown No Underlying failure, retained using standard Error cause semantics.

Construction creates an Error whose name is SiteKitError. Its message includes [code], context, hint and the docs URL. Match code, not message wording. cause may contain transport details or local paths; do not return it verbatim to browser clients or public logs. The class does not retry or authorize operations.

import { defineSite } from '@alneas/sitekit/config';
import { SiteKitError } from '@alneas/sitekit/errors';
try {
defineSite({ id: '', content: { file: './snapshot.json' } });
} catch (error) {
if (error instanceof SiteKitError) console.error(error.code, error.hint, error.docs);
else throw error;
}

A configuration has an empty/invalid ID, ambiguous content sources, unsupported endpoint/method or invalid revision. Supply one content source and a positive safe integer revision when present. Use credential-free HTTPS, or loopback HTTP for local development. The snapshot reader also rejects endpoint query strings and fragments. See configuration.

The build did not obtain a publication. Configure an inline snapshot, file or endpoint. Do not silently substitute another publication. An unconfigured standalone snapshot reader still returns null; the build requires content.

The snapshot file cannot be read, or an HTTP request/body read fails, times out, redirects or returns a non-success status. Check the source and build-only credentials. Native I/O/transport failures remain available as cause when present. A failed reader keeps the rejected promise and does not refetch a newer publication automatically; create a new reader for an intentional retry.

Serialization, JSON syntax, publication validation, the 8 MiB serialized limit or local draft-preview requirements fail. Correct the publication payload; cause retains parse/validation errors when present. Draft previews require explicit local-file preview mode and an unexpired draft marker. Do not disable validation or authorize previews from arbitrary HTTP inputs.

The publication belongs to a different site. Select the intended source. Do not bypass the identity check to render foreign content.

The publication revision differs from the configured expected revision. Select that pinned publication, or intentionally update the expected revision as part of a reviewed content change. This is not a request to retry until a different revision passes.

Image metadata contains an unsafe/malformed URL, unsupported MIME type or conflicting hashes for one URL. Correct the publication metadata. Malformed snapshot hash fields may instead fail earlier with SK_SNAPSHOT_INVALID.

A verified build requires missing image hashes. Publish SHA-256 hashes with the publication. Legacy compatibility remains explicit and does not bypass supplied hashes or a publication declaring SHA-256 integrity.

Downloaded bytes do not match the publication’s hash. Fix the bytes and hash together, then build that intended revision. Do not disable integrity checks.

An image request or streamed body fails, redirects, times out, returns a non-success status or has no body. Check image availability and host access. CMS authentication headers are not forwarded to media origins.

An image declares or streams more than 25 MiB. Resize/re-encode the source and republish matching hashes.

These codes cover failures owned by defineSite, the snapshot reader used by createSiteAstroConfig, and its image-verification step. Direct DTO parsers, storage adapters, Studio HTTP responses and Astro’s own failures are outside this initial code set. Host source/configuration callbacks propagate their original errors unchanged; not every failure is a SiteKitError. Existing instanceof Error handling and diagnostic message substrings remain useful, but exact message text is not a stable API.

Use the JSON Schema guide for editor-time shape checking and the content-source guide for runtime source selection.