{"record":{"id":"69907ea34563fefe","repo":"quarkusio/quarkus","slug":"no-previous-field-type-found","errorCode":null,"errorMessage":"No previous field type found","messagePattern":"No previous field type found","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/bitmap/BitFieldArgs.java","lineNumber":348,"sourceCode":"     */\n    public static Offset offset(int offset) {\n        return new Offset(false, offset);\n    }\n\n    /**\n     * Creates a new {@link Offset} for the given {@code offset} that is multiplied by the integer type width used in the sub\n     * command.\n     *\n     * @param offset offset to be multiplied by the integer type width.\n     * @return the {@link Offset}.\n     */\n    public static Offset typeWidthBasedOffset(int offset) {\n        return new Offset(true, offset);\n    }\n\n    private BitFieldType getPreviousFieldType() {\n        if (previousBitFieldType == null) {\n            throw new IllegalStateException(\"No previous field type found\");\n        } else {\n            return previousBitFieldType;\n        }\n    }\n\n    public List<Object> toArgs() {\n        return commands;\n    }\n\n}\n","sourceCodeStart":330,"sourceCodeEnd":359,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/bitmap/BitFieldArgs.java#L330-L359","documentation":"In BitFieldArgs, the GET/SET/INCRBY variants without an explicit BitFieldType reuse the field type from a previous chained command (previousBitFieldType). getPreviousFieldType() throws this IllegalStateException when the BITFIELD command starts with a type-less GET/SET/INCRBY, so there is no prior type to inherit. Redis BITFIELD requires a type for the first operation.","triggerScenarios":"Calling bfa.get(offset) or bfa.set(offset, value) or bfa.incrBy(offset, value) (the type-less overloads) as the FIRST operation on a fresh BitFieldArgs instance — e.g. new BitFieldArgs().get(0) or new BitFieldArgs().incrBy(offset, 1).","commonSituations":"Building a single-operation BITFIELD command and assuming the type-less overload is self-sufficient; copying code that worked because a earlier .set(bft, ...) call established the type, then removing that call; ordering methods so the typed call comes after the type-less one.","solutions":["Start the chain with a typed overload: set(BitFieldType.INT_8, offset, value), get(BitFieldType.INT_8, offset), or incrBy(BitFieldType.INT_8, offset, value).","Alternatively use the BitFieldArgs.Builder, which tracks the current type automatically.","Reorder the fluent chain so a typed call precedes any type-less call."],"exampleFix":"// before\nBitFieldArgs args = new BitFieldArgs().get(0); // IllegalStateException\n// after\nBitFieldArgs args = new BitFieldArgs().get(BitFieldType.UINT_8, 0);","handlingStrategy":"type-guard","validationCode":"BitFieldArgs args = new BitFieldArgs();\nif (typedCallFirst) {\n    args.set(BitFieldType.INT_8, offset, value); // establish the type first\n} else {\n    args.get(BitFieldType.UINT_8, offset); // never start with the type-less overload\n}","typeGuard":"boolean hasPreviousType(BitFieldArgs args) { return args.toArgs().stream().anyMatch(a -> String.valueOf(a).matches(\"(i|u)\\\\d+\")); }","tryCatchPattern":"try { return args.get(offset); } catch (IllegalStateException e) { if (e.getMessage().contains(\"No previous field type\")) { return args.get(BitFieldType.INT_16, offset); } throw e; }","preventionTips":["Rule of thumb: the FIRST operation in a BITFIELD chain must use the typed overload.","Prefer the BitFieldArgs.Builder so the current type is tracked automatically.","When refactoring chains, check that removing a typed call doesn't orphan later type-less calls."],"tags":["redis","state-error","fluent-api"],"backgroundTag":"missing-required-state","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}