{"record":{"id":"006af2aa9a31dda0","repo":"quarkusio/quarkus","slug":"not-a-valid-type","errorCode":null,"errorMessage":"Not a valid type: ","messagePattern":"Not a valid type: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceImpl.java","lineNumber":396,"sourceCode":"            return delegate.hasNext();\n        }\n\n        @SuppressWarnings(\"unchecked\")\n        @Override\n        public InstanceHandle<H> next() {\n            return getHandle((InjectableBean<H>) delegate.next());\n        }\n\n    }\n\n    private static Type getRequiredType(final Type type) {\n        if (isParameterizedType(type)) {\n            final ParameterizedType parameterizedType = asParameterizedType(type);\n            if (Provider.class.isAssignableFrom(Types.getRawType(parameterizedType.getRawType()))) {\n                return parameterizedType.getActualTypeArguments()[0];\n            }\n        }\n        throw new IllegalArgumentException(\"Not a valid type: \" + type);\n    }\n\n    private boolean isGetCached(Set<Annotation> annotations) {\n        for (Annotation annotation : annotations) {\n            if (annotation.annotationType().equals(WithCaching.class)) {\n                return true;\n            }\n        }\n        return false;\n    }\n\n}\n","sourceCodeStart":378,"sourceCodeEnd":409,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/InstanceImpl.java#L378-L409","documentation":"ArC's Instance support utility getRequiredType(Type) unwraps Provider-like types (Instance, Provider, etc.): if the type is parameterized and its raw type is assignable to Provider, it returns the first type argument; otherwise it throws IllegalArgumentException('Not a valid type: ...'). It signals that a type passed where a Provider-style required type was expected is not parameterized appropriately.","triggerScenarios":"Calling ArC programmatic APIs (e.g. Arc.container().instance(...)/forInjection paths) with a raw (non-parameterized) Instance/Provider type, or a type that does not implement Provider at all.","commonSituations":"Programmatic container lookups built from reflection where the generic parameter was lost (raw Instance instead of Instance<Foo>); wiring helper code that passes the wrapper type rather than the payload type.","solutions":["Pass the parameterized type (Instance<Foo>, Provider<Foo>) so the actual type argument can be extracted","If you don't need lazy lookup, pass the payload type Foo directly instead of the Provider wrapper","Fix reflection code to capture generic super type information (TypeLiteral/ParameterizedType) instead of raw Class"],"exampleFix":"// before\ngetRequiredType(Instance.class); // IAE\n// after\ngetRequiredType(new TypeLiteral<Instance<Foo>>() {}.getType());","handlingStrategy":"validation","validationCode":"static void requireProviderType(Type type) {\n    if (!(type instanceof ParameterizedType pt)\n        || !Provider.class.isAssignableFrom(Types.getRawType(pt.getRawType()))) {\n        throw new IllegalArgumentException(\"Expected parameterized Provider/Instance type: \" + type);\n    }\n}","typeGuard":"static boolean isValidRequiredType(Type t) {\n    return t instanceof ParameterizedType pt\n        && Provider.class.isAssignableFrom(io.quarkus.arc.impl.Types.getRawType(pt.getRawType()));\n}","tryCatchPattern":"try {\n    Type required = getRequiredType(type);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Not a valid type\")) {\n        throw new IllegalStateException(\"Pass a parameterized Instance<Foo>/Provider<Foo> type\", e);\n    }\n    throw e;\n}","preventionTips":["Never use raw Instance/Provider types in programmatic lookups","Capture generics with TypeLiteral or getGenericSuperclass when reflecting","Pass the payload type directly if lazy resolution isn't needed"],"tags":["cdi","arc","generics","reflection"],"backgroundTag":"invalid-generic-type","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}