Trying to render a jinja template file with nested instance-data attributes that isn't provided by the active DataSource fails the init stage and prevent cloud-init from starting up.
## template: jinja
#cloud-config
write_files:
- content: |
{{ ds.meta_data.placement.region | default("fallback") }}
path: /tmp/out
2026-08-16 12:32:28,652 - jinja_template.py[WARNING]: Ignoring jinja template for /etc/cloud/cloud.cfg.d/10_test.cfg: 'dict object' has no attribute 'placement'
2026-08-16 12:32:28,652 - main.py[ERROR]: failed stage init
Traceback (most recent call last):
File "/usr/lib/python3.14/site-packages/cloudinit/cmd/main.py", line 967, in status_wrapper
ret = functor(name, args)
File "/usr/lib/python3.14/site-packages/cloudinit/cmd/main.py", line 582, in main_init
iid = init.instancify()
File "/usr/lib/python3.14/site-packages/cloudinit/stages.py", line 568, in instancify
return self._reflect_cur_instance()
~~~~~~~~~~~~~~~~~~~~~~~~~~^^
... <traces>
File "/usr/lib/python3.14/site-packages/cloudinit/util.py", line 1142, in read_conf_with_confd
confd_cfg = read_conf_d(confd, instance_data_file=instance_data_file)
File "/usr/lib/python3.14/site-packages/cloudinit/util.py", line 1086, in read_conf_d
read_conf(
~~~~~~~~~^
path,
^^^^^
instance_data_file=instance_data_file,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/lib/python3.14/site-packages/cloudinit/util.py", line 359, in read_conf
return load_yaml(config_file, default={}) # pyright: ignore
File "/usr/lib/python3.14/site-packages/cloudinit/util.py", line 976, in load_yaml
blob = decode_binary(blob)
File "/usr/lib/python3.14/site-packages/cloudinit/util.py", line 143, in decode_binary
return blob if isinstance(blob, str) else blob.decode(encoding=encoding)
^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'decode'
failed run of stage init
------------------------------------------------------------
...
<Journal output>
Aug 16 12:32:28 localhost cloud-init[3025]: 2026-08-16 12:32:28,773 - socket.py[CRITICAL]: AttributeError("'NoneType' object has no attribute 'decode'") in <frame at 0x7f1f8b628440, file '/usr/lib/python3.14/site-packages/cloudinit/cmd/main.py', line 1340, code all_stages>
Aug 16 12:32:28 localhost systemd[1]: cloud-init-main.service: Main process exited, code=exited, status=1/FAILURE
Aug 16 12:32:28 localhost systemd[1]: cloud-init-main.service: Failed with result 'exit-code'.
Bug report
Trying to render a jinja template file with nested instance-data attributes that isn't provided by the active DataSource fails the init stage and prevent cloud-init from starting up.
render_jinja_payload_from_file()returns aNonevalue when it can't render a template that isn't syntax related.util.read_conf()doesn't happen to have any checks for thisNonereturn and instead passes it to theload_yaml()function which tries to rundecode_binary(None)and raises the AttributeError.Tracing back. This seems this was removed in #5350 due to mypy warnings as the render functions had no return annotations.
Steps to reproduce the problem
Have a 'None' data source and inspect
cloud-init-main.serviceEnvironment details
Boot on a platform with NoCloud/None datasource where
ds.meta_data.placementisn't available. I thought thedefault()would help but it didn't get triggered.Check the logs.
cloud-init logs