{"record":{"id":"78f1ea9e39bd9c8a","repo":"fluent/fluentd","slug":"sd-file-path-path-couldn-t-open-e","errorCode":null,"errorMessage":"sd_file: path=#{@path} couldn't open #{e}","messagePattern":"sd_file: path=#(.+?) couldn't open #(.+?)","errorType":"exception","errorClass":"Fluent::ConfigError","httpStatus":null,"severity":"error","filePath":"lib/fluent/plugin/sd_file.rb","lineNumber":121,"sourceCode":"\n        drain = @services - s\n        drain.each do |d|\n          diff << ServiceDiscovery.service_out_msg(d)\n        end\n\n        @services = s\n\n        diff.each do |a|\n          queue.push(a)\n        end\n      end\n\n      def fetch_server_info\n        config_data =\n          begin\n            File.open(@path, \"r:#{@conf_encoding}:utf-8\", &:read)\n          rescue => e\n            raise Fluent::ConfigError, \"sd_file: path=#{@path} couldn't open #{e}\"\n          end\n\n        parser.call(config_data).map do |s|\n          Service.new(\n            :file,\n            s.fetch('host'),\n            s.fetch('port'),\n            s['name'],\n            s.fetch('weight', DEFAULT_WEIGHT),\n            s['standby'],\n            s['username'],\n            s['password'],\n            s['shared_key'],\n          )\n        end\n      rescue KeyError => e\n        raise Fluent::ConfigError, \"#{e}. Service must have `host` and `port`\"\n      end","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/fluent/fluentd/blob/dd45c6e18dc7be33b5e5a0f0767bf46307ff5626/lib/fluent/plugin/sd_file.rb#L103-L139","documentation":"SdFileServiceDiscovery#fetch_server_info (lib/fluent/plugin/sd_file.rb:121) opens the services file with File.open(path, 'r:{conf_encoding}:utf-8') and wraps any exception in Fluent::ConfigError. Unlike the not-found case (error 236), this fires when the file exists but cannot be read or decoded: permission denied, encoding name typos, or content that cannot be converted from conf_encoding to UTF-8.","triggerScenarios":"File mode 0600 owned by another user while fluentd runs unprivileged; conf_encoding set to 'utf8' (must be a Ruby encoding name like 'UTF-8' or 'EUC-JP'); a Shift_JIS/EUC-KR file declared as UTF-8 causing an UndefinedConversionError during read.","commonSituations":"Running fluentd as the 'fluent' user on files created by root; Japanese/Korean legacy-encoded service lists; Docker volume mounts that preserve restrictive permissions; copy-pasted conf_encoding values from examples using non-Ruby names.","solutions":["Fix permissions: chown fluent:fluent /etc/fluent/services.yaml or chmod a+r (as appropriate).","Set conf_encoding to the file's real Ruby encoding name (<service_discovery> @type file path ... conf_encoding SJIS </service_discovery>).","Re-save the services file as UTF-8 and drop conf_encoding.","Verify readability as the fluentd user: sudo -u fluent head -1 /etc/fluent/services.yaml."],"exampleFix":"# before\n<service_discovery>\n  @type file\n  path /etc/fluent/servers.yaml\n  conf_encoding utf8       # invalid encoding name\n</service_discovery>\n# after\n<service_discovery>\n  @type file\n  path /etc/fluent/servers.yaml\n  conf_encoding UTF-8\n</service_discovery>","handlingStrategy":"validation","validationCode":"# pre-start readability + encoding probe\nenc = 'UTF-8'\ndata = File.read(path, encoding: \"#{enc}:utf-8\") # raises here if unreadable/undecodable","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Grant the fluentd runtime user read access to the services file.","Declare the real Ruby encoding name in conf_encoding (e.g. SJIS, EUC-JP) or re-save the file as UTF-8.","Verify as the daemon user: sudo -u fluent cat path >/dev/null."],"tags":["fluentd","service-discovery","config-error","file-permissions","encoding"],"backgroundTag":"file-open-failed","analyzedSha":"dd45c6e18dc7be33b5e5a0f0767bf46307ff5626","analyzedAt":"2026-08-21T16:22:07.332Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}