xpipe-io/xpipe · error · ValidationException

Value must be an instance of ${className}

Error message

Value must be an instance of ${className}

What it means

Validators.isType(DataStoreEntryRef ref, Class c) validates that a store reference points to a store of the expected type. It throws a ValidationException when the ref is null, the referenced store is null, or the store's class is not assignable from c. This guards option/configuration fields that must reference a specific DataStore implementation.

Source

Thrown at app/src/main/java/io/xpipe/app/util/Validators.java:17

package io.xpipe.app.util;

import io.xpipe.app.core.AppI18n;
import io.xpipe.app.storage.DataStoreEntryRef;
import io.xpipe.app.store.DataStore;

import java.util.Arrays;
import java.util.List;

public class Validators {

    public static <T extends DataStore> void isType(DataStoreEntryRef<? extends T> ref, Class<T> c)
            throws ValidationException {
        if (ref == null
                || ref.getStore() == null
                || !c.isAssignableFrom(ref.getStore().getClass())) {
            throw new ValidationException("Value must be an instance of " + c.getSimpleName());
        }
    }

    public static <T extends DataStore> void isAnyType(DataStoreEntryRef<? extends T> ref, Class<?>... cs)
            throws ValidationException {
        if (ref == null
                || ref.getStore() == null
                || Arrays.stream(cs)
                        .noneMatch(c -> c.isAssignableFrom(ref.getStore().getClass()))) {
            throw new ValidationException("Value must be an instance of "
                    + Arrays.stream(cs).map(Class::getSimpleName).toList());
        }
    }

    public static void nonNull(Object object) throws ValidationException {
        if (object == null) {
            throw new ValidationException(AppI18n.get("valueMustNotBeEmpty"));
        }

View on GitHub (pinned to d85ca821ba)

Solutions

  1. Ensure the user/config selects a store entry of the required type before validation runs.
  2. Check the reference before validating: if (ref != null && c.isInstance(ref.getStore())) proceed.
  3. Restrict the store picker to entries matching the required store class so invalid selections cannot occur.

Example fix

// before
Validators.isType(ref, ScriptStore.class);
// after
if (ref != null && ref.getStore() != null && ScriptStore.class.isInstance(ref.getStore())) {
    Validators.isType(ref, ScriptStore.class);
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (ref == null || ref.getStore() == null || !c.isInstance(ref.getStore())) {
    // resolve or reject before calling Validators.isType
}

Type guard

public static <T extends DataStore> boolean isStoreType(DataStoreEntryRef<?> ref, Class<T> c) {
    return ref != null && ref.getStore() != null && c.isInstance(ref.getStore());
}

Try / catch

try {
    Validators.isType(ref, MyStore.class);
} catch (ValidationException e) {
    // wrong or dangling store type; ask user to reselect
}

Prevention

When it happens

Trigger: Calling Validators.isType(ref, SomeStore.class) where ref is null, ref.getStore() is null, or the referenced entry's store is a different DataStore subclass than c.

Common situations: A user selected a connection of the wrong kind in a dialog (e.g. a generic store where an SSH connection is required); a store entry was deleted so the ref dangles; validation runs before the store is resolved.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of xpipe-io/xpipe@d85ca821ba (2026-09-06). Data as JSON: /api/errors/97725f36108adfd7. Report an issue: GitHub.