{"record":{"id":"9f4511f9a4602a05","repo":"yuliskov/SmartTube","slug":"content-type-must-be-greater-or-less-than-0","errorCode":null,"errorMessage":"content type must be greater or less than '0'!","messagePattern":"content type must be greater or less than '0'!","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"chatkit/src/main/java/com/stfalcon/chatkit/messages/MessageHolders.java","lineNumber":483,"sourceCode":"     * Registers custom content type (e.g. multimedia, events etc.)\n     *\n     * @param type            unique id for content type\n     * @param incomingHolder  holder class for incoming message\n     * @param outcomingHolder holder class for outcoming message\n     * @param incomingLayout  layout resource for incoming message\n     * @param outcomingLayout layout resource for outcoming message\n     * @param contentChecker  {@link ContentChecker} for registered type\n     * @return {@link MessageHolders} for subsequent configuration.\n     */\n    public <TYPE extends MessageContentType>\n    MessageHolders registerContentType(\n            byte type,\n            @NonNull Class<? extends BaseMessageViewHolder<TYPE>> incomingHolder, @LayoutRes int incomingLayout,\n            @NonNull Class<? extends BaseMessageViewHolder<TYPE>> outcomingHolder, @LayoutRes int outcomingLayout,\n            @NonNull ContentChecker contentChecker) {\n\n        if (type == 0)\n            throw new IllegalArgumentException(\"content type must be greater or less than '0'!\");\n\n        customContentTypes.add(\n                new ContentTypeConfig<>(type,\n                        new HolderConfig<>(incomingHolder, incomingLayout),\n                        new HolderConfig<>(outcomingHolder, outcomingLayout)));\n        this.contentChecker = contentChecker;\n        return this;\n    }\n\n    /**\n     * Registers custom content type (e.g. multimedia, events etc.)\n     *\n     * @param type             unique id for content type\n     * @param incomingHolder   holder class for incoming message\n     * @param outcomingHolder  holder class for outcoming message\n     * @param incomingPayload  payload for incoming message\n     * @param outcomingPayload payload for outcoming message\n     * @param incomingLayout   layout resource for incoming message","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/yuliskov/SmartTube/blob/3de8d90593e0166f012ca18cc3c7ba45bfd68ac4/chatkit/src/main/java/com/stfalcon/chatkit/messages/MessageHolders.java#L465-L501","documentation":"MessageHolders encodes message direction in the sign of the view type (positive incoming, negative outcoming), so byte 0 cannot represent a usable content type and registerContentType rejects it up front with IllegalArgumentException. Built-in view types occupy 130-133 (date header, text, image, string header); registration happens once, before the adapter is used.","triggerScenarios":"Calling registerContentType((byte) 0, incomingHolder, ..., contentChecker) with a default-initialized type constant, or a loop that starts numbering custom types at 0.","commonSituations":"Porting an enum of content types whose ordinal starts at zero; copy-pasting a registration block and forgetting to change the type byte; auto-generated type tables beginning at 0.","solutions":["Use a non-zero byte for the content type, e.g. (byte) 1","Start generated/looped type numbering at 1 and keep values unique across registrations","Keep custom types out of the built-in range 130-133 so getViewHolder routes them to your holders instead of the defaults"],"exampleFix":"// before\nholders.registerContentType((byte) 0, InVH.class, R.layout.in, OutVH.class, R.layout.out, checker);\n\n// after\nholders.registerContentType((byte) 1, InVH.class, R.layout.in, OutVH.class, R.layout.out, checker);","handlingStrategy":"validation","validationCode":"if (type == 0) throw new IllegalArgumentException(\"content type must be non-zero\");\nholders.registerContentType(type, inHolder, inLayout, outHolder, outLayout, checker);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Define content-type constants once, starting at 1 (e.g. TYPE_QUOTES = 1)","Never derive type bytes from enum ordinal() without offsetting by 1","Keep custom types outside the built-in 130-133 range"],"tags":["chatkit","messages","content-type","registration","validation"],"backgroundTag":"invalid-content-type-code","analyzedSha":"3de8d90593e0166f012ca18cc3c7ba45bfd68ac4","analyzedAt":"2026-08-22T09:19:26.383Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}