{"record":{"id":"776e8839cb57cb45","repo":"OpenRefine/OpenRefine","slug":"unsupported-entity-type","errorCode":null,"errorMessage":"Unsupported entity type","messagePattern":"Unsupported entity type","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/wikibase/src/org/openrefine/wikibase/qa/SchemaPropertyExtractor.java","lineNumber":36,"sourceCode":"import org.openrefine.wikibase.schema.WbSnakExpr;\nimport org.openrefine.wikibase.schema.WbStatementExpr;\nimport org.openrefine.wikibase.schema.WbStatementGroupExpr;\nimport org.openrefine.wikibase.schema.WikibaseSchema;\nimport org.openrefine.wikibase.updates.EntityEdit;\n\npublic class SchemaPropertyExtractor {\n\n    public Set<PropertyIdValue> getAllProperties(WikibaseSchema schema) {\n        Set<PropertyIdValue> properties = new HashSet<>();\n        List<WbExpression<? extends EntityEdit>> entityDocumentExprs = schema.getEntityDocumentExpressions();\n        for (WbExpression<? extends EntityEdit> entityDocumentExpr : entityDocumentExprs) {\n            List<WbStatementGroupExpr> statementGroups = Collections.emptyList();\n            if (entityDocumentExpr instanceof WbItemEditExpr) {\n                statementGroups = ((WbItemEditExpr) entityDocumentExpr).getStatementGroups();\n            } else if (entityDocumentExpr instanceof WbMediaInfoEditExpr) {\n                statementGroups = ((WbMediaInfoEditExpr) entityDocumentExpr).getStatementGroups();\n            } else {\n                throw new IllegalStateException(\"Unsupported entity type\");\n            }\n            for (WbStatementGroupExpr statementGroup : statementGroups) {\n                WbExpression<? extends PropertyIdValue> statementGroupProperty = statementGroup.getProperty();\n                if (statementGroupProperty instanceof WbPropConstant) {\n                    properties.add(Datamodel.makeWikidataPropertyIdValue(((WbPropConstant) statementGroupProperty).getPid()));\n                }\n                List<WbStatementExpr> statementExprs = statementGroup.getStatements();\n                for (WbStatementExpr statementExpr : statementExprs) {\n                    List<WbSnakExpr> snakExprs = new ArrayList<>(statementExpr.getQualifiers());\n                    List<WbReferenceExpr> referenceExprs = statementExpr.getReferences();\n                    for (WbReferenceExpr referenceExpr : referenceExprs) {\n                        snakExprs.addAll(referenceExpr.getSnaks());\n                    }\n\n                    for (WbSnakExpr snakExpr : snakExprs) {\n                        WbExpression<? extends PropertyIdValue> qualifierProperty = snakExpr.getProp();\n                        if (qualifierProperty instanceof WbPropConstant) {\n                            properties.add(Datamodel.makeWikidataPropertyIdValue(((WbPropConstant) qualifierProperty).getPid()));","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/OpenRefine/OpenRefine/blob/a946177e049f3b0644261661db36cbb0c81ccf8a/extensions/wikibase/src/org/openrefine/wikibase/qa/SchemaPropertyExtractor.java#L18-L54","documentation":"SchemaPropertyExtractor.getAllProperties extracts property IDs from a schema's entity document expressions, but it only handles WbItemEditExpr and WbMediaInfoEditExpr; any other expression type throws IllegalStateException 'Unsupported entity type'. The QA scrutinizer pipeline relies on this to know which properties to fetch from the entity cache.","triggerScenarios":"Running QA inspection (EditInspector -> properties()/propertyIdValues() -> getAllProperties) on a schema whose top-level expression is neither a WbItemEditExpr nor a WbMediaInfoEditExpr — e.g. a WbItemEditExpr variant for entity types like Property or Lexeme not covered by the extractor.","commonSituations":"Editing Wikibase Properties or Lexemes (not Items/MediaInfo) and running the QA check; using a manifest for a Wikibase whose primary entity type is unsupported by the extractor; older OpenRefine versions lacking support for newer entity types.","solutions":["Run QA only on schemas editing Items or MediaInfo entities, or add a branch for the missing expression type (e.g. WbPropertyEditExpr/WbLexemeEditExpr) in SchemaPropertyExtractor.","Check which entity type your manifest/schema targets and switch to an OpenRefine version that supports it.","Catch the IllegalStateException in custom QA tooling and skip property extraction for unsupported entity types.","File/verify an upstream issue for the entity type you need if it is a legitimate new type."],"exampleFix":"// before: extractor chokes on new entity types\n} else if (entityDocumentExpr instanceof WbMediaInfoEditExpr) {\n    statementGroups = ((WbMediaInfoEditExpr) entityDocumentExpr).getStatementGroups();\n} else {\n    throw new IllegalStateException(\"Unsupported entity type\");\n}\n\n// after: extend coverage\n} else if (entityDocumentExpr instanceof WbMediaInfoEditExpr) {\n    statementGroups = ((WbMediaInfoEditExpr) entityDocumentExpr).getStatementGroups();\n} else if (entityDocumentExpr instanceof WbPropertyEditExpr) {\n    statementGroups = ((WbPropertyEditExpr) entityDocumentExpr).getStatementGroups();\n} else {\n    throw new IllegalStateException(\"Unsupported entity type\");\n}","handlingStrategy":"validation","validationCode":"boolean supported = schema.getEntityDocumentExpr() instanceof WbItemEditExpr\n    || schema.getEntityDocumentExpr() instanceof WbMediaInfoEditExpr;\nif (!supported) { /* skip property extraction / QA for this entity type */ }","typeGuard":"if (!(expr instanceof WbItemEditExpr) && !(expr instanceof WbMediaInfoEditExpr)) {\n    // unsupported entity type: skip QA property extraction\n}","tryCatchPattern":"try {\n    editInspector.inspect(editBatch);\n} catch (ExecutionException e) {\n    if (e.getCause() instanceof IllegalStateException\n            && \"Unsupported entity type\".equals(e.getCause().getMessage())) {\n        logger.warn(\"QA property extraction not supported for this entity type; skipping\");\n    } else throw e;\n}","preventionTips":["Run QA inspection only for Item and MediaInfo editing schemas","Check the manifest's target entity type before enabling QA","Extend SchemaPropertyExtractor when adding support for new entity types"],"tags":["wikibase","schema","entity-type","qa","unsupported"],"backgroundTag":"unsupported-enum-value","analyzedSha":"a946177e049f3b0644261661db36cbb0c81ccf8a","analyzedAt":"2026-09-08T10:21:27.735Z","contentChangedAt":"2026-09-08T10:21:27.735Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}