GraphiteEditor/Graphite · error

ApplicationIo must be available when using resources

Error message

ApplicationIo must be available when using resources

What it means

The resource node in gstd loads a stored platform resource by content hash through the PlatformEditorApi injected from the graph scope, and .expect panics when the editor API carries no ApplicationIo (the platform's IO backend that owns resource storage). This means the graph was evaluated in an environment that does not provide platform resource storage: headless tests, CLI/WASM hosts, or a scope where the editor_api entry was registered without application_io.

Source

Thrown at node-graph/nodes/gstd/src/platform_application_io.rs:293

	)
}

#[node_macro::node(category(""), inject_scope)]
pub async fn editor_api<'a: 'n>(_: impl Ctx, #[scope("editor-api")] editor_api: Item<&'a PlatformEditorApi>) -> Item<&'a PlatformEditorApi> {
	editor_api
}

#[node_macro::node(category(""))]
pub async fn resource<'a: 'n>(
	_: impl Ctx,
	/// The scope-provided editor API giving access to the platform's resource storage.
	#[scope(editor_api::IDENTIFIER)]
	editor_api: Item<&'a PlatformEditorApi>,
	/// The content hash identifying which stored resource to load.
	hash: Item<ResourceHash>,
) -> Item<Resource> {
	let hash = hash.into_element();
	let application_io = editor_api.into_element().application_io.as_ref().expect("ApplicationIo must be available when using resources");
	let resource = application_io.load_resource(hash).await.unwrap_or_else(|| panic!("Resource {hash} not found"));
	Item::new_from_element(resource)
}

#[node_macro::node(category(""), inject_scope)]
pub async fn wgpu_executor<'a: 'n>(_: impl Ctx, #[scope(editor_api::IDENTIFIER)] editor_api: Item<&'a PlatformEditorApi>) -> Item<&'a ::wgpu_executor::WgpuExecutor> {
	let executor = editor_api
		.into_element()
		.application_io
		.as_ref()
		.expect("ApplicationIo not available")
		.gpu_executor()
		.expect("GPU executor not available");
	Item::new_from_element(executor)
}

#[node_macro::node(category(""), inject_scope)]
pub async fn try_wgpu_executor<'a: 'n>(_: impl Ctx, #[scope(editor_api::IDENTIFIER)] editor_api: Item<&'a PlatformEditorApi>) -> Item<Option<&'a ::wgpu_executor::WgpuExecutor>> {

View on GitHub (pinned to c507b35645)

Solutions

  1. Run or evaluate the graph inside the platform/editor that constructs PlatformEditorApi with application_io set, so resource storage is reachable
  2. If you host evaluation yourself, provide an ApplicationIo implementation (resource load/store backend) on the editor_api scope entry before evaluating resource nodes
  3. Replace the .expect with an explicit evaluation error so a missing platform backend surfaces as a node failure instead of a panic
  4. For portable/headless graphs, avoid the resource node: load the data through your own IO and feed it into the graph directly

Example fix

// before (host evaluates graph, scope lacks IO)
let application_io = editor_api.into_element().application_io.as_ref().expect("ApplicationIo must be available when using resources");

// after (host side): construct the scope entry with the platform IO present so the expect never fires
let editor_api = PlatformEditorApi { application_io: Some(platform_io), /* ... */ };
// then insert it under editor_api::IDENTIFIER before evaluating the document
Defensive patterns

Strategy: validation

Validate before calling

// Host-side: before evaluating a graph containing resource nodes, verify the scope provides platform IO
let has_io = scope
    .extract::<&PlatformEditorApi>(editor_api::IDENTIFIER)
    .map(|api| api.application_io.is_some())
    .unwrap_or(false);
if !has_io {
    // skip evaluation, or provide an ApplicationIo before running resource nodes
}

Type guard

fn has_application_io(api: &PlatformEditorApi) -> bool {
    api.application_io.is_some()
}

Try / catch

let outcome = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| evaluate_document(doc)));
if outcome.is_err() {
    // report the failing resource node (message starts with "ApplicationIo must be available") instead of crashing the host
}

Prevention

When it happens

Trigger: Evaluating a document containing the resource node outside the full editor platform; hosting the node graph yourself and injecting an editor_api::IDENTIFIER scope item whose application_io field is None; programmatic graph evaluation in tests or an export pipeline with no platform IO wired up.

Common situations: Editor-authored graphs run in CI; a new platform port that has not wired ApplicationIo yet; refactors that change how PlatformEditorApi is constructed so application_io is left unset in some builds.

Related errors


AI-assisted analysis of GraphiteEditor/Graphite@c507b35645 (2026-08-16). Data as JSON: /api/errors/2fb5f19885b5c0c7. Report an issue: GitHub.