{"record":{"id":"4889ac5a94c17a72","repo":"fluent/fluentd","slug":"optional-api-parse-partial-data-is-not-implemente","errorCode":null,"errorMessage":"Optional API #parse_partial_data is not implemented","messagePattern":"Optional API #parse_partial_data is not implemented","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin/parser.rb","lineNumber":178,"sourceCode":"        parse(*a, &b)\n      end\n\n      def implement?(feature)\n        methods_of_plugin = self.class.instance_methods(false)\n        case feature\n        when :parse_io then methods_of_plugin.include?(:parse_io)\n        when :parse_partial_data then methods_of_plugin.include?(:parse_partial_data)\n        else\n          raise ArgumentError, \"Unknown feature for parser plugin: #{feature}\"\n        end\n      end\n\n      def parse_io(io, &block)\n        raise NotImplementedError, \"Optional API #parse_io is not implemented\"\n      end\n\n      def parse_partial_data(data, &block)\n        raise NotImplementedError, \"Optional API #parse_partial_data is not implemented\"\n      end\n\n      def parse_time(record)\n        if @time_key && record.respond_to?(:has_key?) && record.has_key?(@time_key)\n          src = if @keep_time_key\n                  record[@time_key]\n                else\n                  record.delete(@time_key)\n                end\n          @time_parser.parse(src)\n        elsif @estimate_current_event\n          Fluent::EventTime.now\n        else\n          nil\n        end\n      rescue Fluent::TimeParser::TimeParseError => e\n        raise ParserError, e.message\n      end","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/parser.rb#L160-L196","documentation":"Second optional parser API guard (lib/fluent/plugin/parser.rb:178): base Parser#parse_partial_data raises NotImplementedError unless the concrete class overrides it (msgpack does via alias). It exists for parsers that can consume partial bytes from a stream; in_exec/out_exec_filter call it behind implement?(:parse_partial_data). Direct invocation on an unsupported parser triggers this error.","triggerScenarios":"Calling parser.parse_partial_data(chunk) on @type json/regexp/csv parsers; custom dispatch code that skips the implement?(:parse_partial_data) check; a subclass defining parse_partial_data= as an assignment or with different arity so the base method remains callable.","commonSituations":"Custom plugins imitating out_exec_filter's readpartial loop but calling parse_partial_data unconditionally; fluentd version changes where a parser type dropped/gained the method; monkey-patches registering parsers through compat layers that hide real method definitions.","solutions":["Guard every call with parser.implement?(:parse_partial_data) and fall back to parser.parse(data).","For binary/streaming sources prefer @type msgpack, which implements parse_partial_data.","In custom parsers, define def parse_partial_data(data, &block) rather than relying on the inherited base."],"exampleFix":"# before\n@parser.parse_partial_data(io.readpartial(@read_block_size), &method(:on_record))\n# after\nif @parser.implement?(:parse_partial_data)\n  @parser.parse_partial_data(io.readpartial(@read_block_size), &method(:on_record))\nelse\n  @parser.parse(io.readpartial(@read_block_size), &method(:on_record))\nend","handlingStrategy":"validation","validationCode":"if @parser.implement?(:parse_partial_data)\n  @parser.parse_partial_data(data, &callback)\nelse\n  @parser.parse(data, &callback)\nend","typeGuard":"def partial_data_capable?(parser)\n  parser.class.instance_methods(false).include?(:parse_partial_data)\nend","tryCatchPattern":"begin\n  @parser.parse_partial_data(chunk, &callback)\nrescue NotImplementedError\n  @parser.parse(chunk, &callback)\nend","preventionTips":["Use @type msgpack for stream/partial-data sources.","Define parse_partial_data in your own parser rather than calling the base.","Cover both dispatch branches in plugin tests."],"tags":["fluentd","parser-plugin","not-implemented","optional-api","streaming"],"backgroundTag":"abstract-method-not-implemented","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}