1919import org .openmetadata .schema .type .EntityReference ;
2020import org .openmetadata .schema .type .Include ;
2121import org .openmetadata .schema .type .TagLabel ;
22+ import org .openmetadata .schema .utils .JsonUtils ;
2223import org .openmetadata .service .Entity ;
2324import org .openmetadata .service .exception .EntityNotFoundException ;
2425import org .openmetadata .service .jdbi3 .EntityRepository ;
@@ -189,17 +190,17 @@ public List<EntityReference> getDomains() {
189190 }
190191
191192 @ Override
192- @ SuppressWarnings ("unchecked" )
193193 public Map <String , Object > getCustomProperties () {
194194 resolveEntity ();
195- if (entity == null ) {
195+ if (entity == null || entity . getExtension () == null ) {
196196 return Collections .emptyMap ();
197197 }
198- Object extension = entity .getExtension ();
199- if (extension instanceof Map ) {
200- return (Map <String , Object >) extension ;
198+ try {
199+ return JsonUtils .getMap (entity .getExtension ());
200+ } catch (Exception e ) {
201+ LOG .warn ("Failed to get custom properties: {}" , e .getMessage ());
202+ return Collections .emptyMap ();
201203 }
202- return Collections .emptyMap ();
203204 }
204205
205206 private EntityInterface resolveEntity () {
@@ -226,7 +227,9 @@ private EntityInterface resolveEntity() {
226227 if (entityRepository .isSupportsReviewers ()) {
227228 fields = EntityUtil .addField (fields , Entity .FIELD_REVIEWERS );
228229 }
229- fields = EntityUtil .addField (fields , FIELD_EXTENSION );
230+ if (supportsExtension ()) {
231+ fields = EntityUtil .addField (fields , FIELD_EXTENSION );
232+ }
230233 fieldList = entityRepository .getFields (fields );
231234 }
232235
@@ -268,5 +271,13 @@ private boolean useRepositoryCache() {
268271 return operation != ResourceContextInterface .Operation .PATCH
269272 && operation != ResourceContextInterface .Operation .PUT ;
270273 }
274+
275+ private boolean supportsExtension () {
276+ try {
277+ return entityRepository .getFields (FIELD_EXTENSION ) != null ;
278+ } catch (Exception e ) {
279+ return false ;
280+ }
281+ }
271282}
272283
0 commit comments