{"record":{"id":"6c3366e8eb63dff3","repo":"alibaba/spring-ai-alibaba","slug":"error-6c3366","errorCode":null,"errorMessage":"解析属性过滤条件失败: {}","messagePattern":"解析属性过滤条件失败: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/repository/impl/TracingQueryBuilder.java","lineNumber":252,"sourceCode":"\n    /**\n     * 添加属性过滤条件\n     */\n    private void addAttributesFilter(BoolQuery.Builder boolQuery, String attributesJson) {\n        try {\n            @SuppressWarnings(\"unchecked\")\n            Map<String, Object> attributesMap = objectMapper.readValue(attributesJson, Map.class);\n            \n            for (Map.Entry<String, Object> entry : attributesMap.entrySet()) {\n                String field = \"attributes.\" + entry.getKey();\n                Query attrQuery = Query.of(q -> q.term(t -> t\n                    .field(field)\n                    .value(String.valueOf(entry.getValue()))\n                ));\n                boolQuery.filter(attrQuery);\n            }\n        } catch (Exception e) {\n            log.warn(\"解析属性过滤条件失败: {}\", attributesJson, e);\n        }\n    }\n\n\n\n    /**\n     * 将ISO8601时间字符串转换为微秒时间戳\n     */\n    private Long convertISO8601ToMicroseconds(String iso8601Time) {\n        try {\n            java.time.Instant instant = java.time.Instant.parse(iso8601Time);\n            // 转换为微秒\n            return instant.toEpochMilli() * 1000;\n        } catch (Exception e) {\n            log.error(\"时间转换失败: {}\", iso8601Time, e);\n            return null;\n        }\n    }","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/repository/impl/TracingQueryBuilder.java#L234-L270","documentation":"TracingQueryBuilder builds an Elasticsearch-style query from a trace search request. When the 'attributes' filter JSON supplied by the client cannot be parsed or turned into field/value term filters, the builder logs this warning and silently drops the attribute filters instead of failing the request.","triggerScenarios":"buildTracesQuery -> addAttributesFilter receives attributesJson that is malformed JSON, not a JSON object, or contains nested/complex values that cannot be converted to a simple term query; the catch(Exception) around JSON parsing/filter construction fires.","commonSituations":"Frontend sending attributes as single-quoted or non-object JSON; passing an array instead of a map; values that are nested objects; URL-decoding issues stripping quotes from the JSON.","solutions":["Fix the client to send attributes as a valid JSON object, e.g. {\"http.status_code\":\"500\"}","Log and inspect the actual attributesJson value in the warning to find the syntax problem","Server-side: validate/normalize the JSON before parsing and return a 400 for invalid input instead of silently dropping filters"],"exampleFix":"// before\nString attrs = \"{'key':'value'}\"; // single quotes\n// after\nString attrs = \"{\\\"key\\\":\\\"value\\\"}\"; // valid JSON object","handlingStrategy":"validation","validationCode":"if (attributesJson == null || attributesJson.isBlank()) throw new IllegalArgumentException(\"attributes must be a JSON object\");\nObject o = new com.fasterxml.jackson.databind.ObjectMapper().readValue(attributesJson, Object.class);\nif (!(o instanceof Map)) throw new IllegalArgumentException(\"attributes must be a JSON object, got: \" + o.getClass());","typeGuard":"boolean isValidAttributesJson(String s) {\n    try { return new ObjectMapper().readValue(s, Map.class) != null; }\n    catch (Exception e) { return false; }\n}","tryCatchPattern":"try { queryBuilder.buildTracesQuery(req); } catch (IllegalArgumentException e) { return ResponseEntity.badRequest().body(\"invalid attributes filter: \" + e.getMessage()); }","preventionTips":["Always send attributes as a JSON object with string/number values","URL-encode JSON query params properly","Validate filters client-side before submitting the trace search"],"tags":["elasticsearch","json","query-builder","tracing"],"backgroundTag":"json-parse-error","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}