Skip to content

Conversation

@megaserg
Copy link

@megaserg megaserg commented May 27, 2025

Problem: On master, ./kapitan c fails with:

pydantic_core._pydantic_core.ValidationError: 1 validation error for GoogleManagedCertificate
namespace
  Input should be a valid string [type=string_type, input_value=Dict({}), input_type=Dict]

Full stacktrace:

Traceback (most recent call last):
  File "/opt/venv/lib/python3.11/site-packages/kapitan/inputs/kadet.py", line 129, in compile_file
    output_obj = kadet_module.main(input_params)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/megaserg/work/kapitan-templates/system/generators/kubernetes/__init__.py", line 16, in main
    store = generator.generate()
            ^^^^^^^^^^^^^^^^^^^^
  File "/Users/megaserg/work/kapitan-templates/system/lib/kgenlib/__init__.py", line 718, in generate
    self.expand_and_run(generator_function=func, generator_params=params)
  File "/Users/megaserg/work/kapitan-templates/system/lib/kgenlib/__init__.py", line 688, in expand_and_run
    self._run_generator_function(
  File "/Users/megaserg/work/kapitan-templates/system/lib/kgenlib/__init__.py", line 660, in _run_generator_function
    self.store.add(generator_function.generate(meta=generator_function_params))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/megaserg/work/kapitan-templates/system/lib/kgenlib/__init__.py", line 326, in generate
    return cls(**meta)
           ^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/kadet/__init__.py", line 214, in __init__
    self.body()
  File "/Users/megaserg/work/kapitan-templates/system/generators/kubernetes/networking.py", line 413, in body
    GoogleManagedCertificate(
  File "/opt/venv/lib/python3.11/site-packages/kadet/__init__.py", line 206, in __init__
    super().__init__(**data)
  File "/opt/venv/lib/python3.11/site-packages/pydantic/main.py", line 212, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for GoogleManagedCertificate
namespace
  Input should be a valid string [type=string_type, input_value=Dict({}), input_type=Dict]
    For further information visit https://errors.pydantic.dev/2.9/v/string_type

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/venv/lib/python3.11/site-packages/kapitan/inputs/base.py", line 77, in compile_input_path
    self.compile_file(
  File "/opt/venv/lib/python3.11/site-packages/kapitan/inputs/kadet.py", line 135, in compile_file
    raise CompileError(f"Could not load Kadet module: {spec.name[16:]}")
kapitan.errors.CompileError: Could not load Kadet module: kubernetes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/venv/lib/python3.11/site-packages/kapitan/targets.py", line 303, in compile_target
    input_compiler.compile_obj(comp_obj, ext_vars, **kwargs)
  File "/opt/venv/lib/python3.11/site-packages/kapitan/inputs/base.py", line 58, in compile_obj
    self.compile_input_path(input_path, comp_obj, ext_vars, **kwargs)
  File "/opt/venv/lib/python3.11/site-packages/kapitan/inputs/base.py", line 88, in compile_input_path
    raise CompileError("{}\nCompile error: failed to compile target: {}".format(e, target_name))
kapitan.errors.CompileError: Could not load Kadet module: kubernetes
Compile error: failed to compile target: prod-sockshop

Cause: Seems like namespace is required and empty, making it become a default value {}.

Solution: Add a namespace to the certificate config.

Result: ./kapitan c works, and the generated manifest compiled/prod-sockshop/manifests/gke-managed-certificate-managed-certificate.yml now contains: namespace: prod-sockshop.

@fg91
Copy link

fg91 commented Sep 26, 2025

I can confirm that this issue exists in the getting started guide when using the latest releaes (0.34.7) and that it is solved by the fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants