{"record":{"id":"f785b1eda2e120b1","repo":"apache/skywalking","slug":"time-field-is-required-when-uuid-is-absent","errorCode":null,"errorMessage":"time field is required when uuid is absent.","messagePattern":"time field is required when uuid is absent\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/EventQueryService.java","lineNumber":59,"sourceCode":"\n    private final ModuleManager moduleManager;\n\n    private IEventQueryDAO dao;\n\n    public EventQueryService(ModuleManager moduleManager) {\n        this.moduleManager = moduleManager;\n    }\n\n    private IEventQueryDAO getDao() {\n        if (dao == null) {\n            dao = moduleManager.find(StorageModule.NAME).provider().getService(IEventQueryDAO.class);\n        }\n        return dao;\n    }\n\n    public Events queryEvents(final EventQueryCondition condition) throws Exception {\n        if (isBlank(condition.getUuid()) && isDurationInvalid(condition.getTime())) {\n            throw new IllegalArgumentException(\"time field is required when uuid is absent.\");\n        }\n        Events events = getDao().queryEvents(condition);\n        return mergeAndSortEvents(events, condition.getOrder());\n    }\n\n    public Events queryEvents(final List<EventQueryCondition> conditions) throws Exception {\n        EventQueryCondition condition = conditions.stream().filter(c -> isBlank(c.getUuid()) && isDurationInvalid(c.getTime())).findFirst().orElse(null);\n        if (Objects.nonNull(condition)) {\n            throw new IllegalArgumentException(\"time field is required when uuid is absent.\");\n        }\n        Events events = getDao().queryEvents(conditions);\n        return mergeAndSortEvents(events, conditions.get(0).getOrder());\n    }\n\n    boolean isDurationInvalid(final Duration duration) {\n        return isNull(duration) || (isBlank(duration.getStart()) || isBlank(duration.getEnd()));\n    }\n","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/EventQueryService.java#L41-L77","documentation":"EventQueryService.queryEvents() requires every query condition to be scoped: either a specific event 'uuid' or a 'time' range with both start and end. When uuid is blank AND the time Duration is null or missing start/end (isDurationInvalid), the DAO filter would match unbounded data, so the service throws IllegalArgumentException before touching storage. The same rule applies to every condition in the list overload (error 268).","triggerScenarios":"Calling queryEvents with an EventQueryCondition that has no 'uuid' and either no 'time' object, or a Duration whose start/end strings are blank.","commonSituations":"UI 'Events' tab sending only a metric-name or scope filter without a time window; GraphQL clients omitting time because they assume a server default; constructing conditions programmatically and forgetting setTime().","solutions":["Add a time window to the condition: time.start and time.end (formatted per the step, e.g. '2026-08-14 1000' for MINUTE).","Or, when looking up one known event, set condition.uuid instead.","For the list overload, ensure every element in conditions satisfies the same rule — the service scans the list and rejects the first invalid entry."],"exampleFix":"# GraphQL — before\ncondition: { source: Service, name: \"my-service\" }\n\n# after\ncondition: { source: Service, name: \"my-service\", time: { step: MINUTE, start: \"2026-08-14 0800\", end: \"2026-08-14 1200\" } }","handlingStrategy":"validation","validationCode":"boolean scoped = isNotBlank(condition.getUuid())\n    || (condition.getTime() != null\n        && isNotBlank(condition.getTime().getStart())\n        && isNotBlank(condition.getTime().getEnd()));\nif (!scoped) condition.setTime(lastHalfHourDuration()); // or reject","typeGuard":"boolean isEventQueryScopesValid(EventQueryCondition c) { return c != null && (StringUtils.isNotBlank(c.getUuid()) || (c.getTime() != null && StringUtils.isNotBlank(c.getTime().getStart()) && StringUtils.isNotBlank(c.getTime().getEnd()))); }","tryCatchPattern":"try { events = eventQueryService.queryEvents(condition); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"time field is required\")) { condition.setTime(defaultWindow()); events = eventQueryService.queryEvents(condition); } else throw e; }","preventionTips":["Always attach a time window in UI/API clients — never rely on a server default.","Use uuid only for single-event deep links.","Centralize condition building in one client helper that enforces scoping."],"tags":["query","events","validation","graphql"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}