konveyor / kai

Konveyor AI - static code analysis driven migration to new targets via Generative AI
Apache License 2.0
23 stars 29 forks source link

Mismatch of config.toml with git checkout and image in podman compose: pydantic_core._pydantic_core.ValidationError: 1 validation error for KaiConfig - Unable to extract tag using discriminator 'provider' [type=union_tag_not_found, input_value={'solution_detectors': 'n...'password': 'dog8code'}}, input_type=dict] #264

Closed jwmatthews closed 1 week ago

jwmatthews commented 1 month ago

I think the below is due to a mismatch where we are tagging images to isolate all changes, but we allow the config to be modified and used from the local checkout.

So in my situation:' -> running podman compose up that uses a :stable tag pointing to: commit 65a5761d479d84c15ccf0769e2bf00ea71a4836c -> My kai checkout of 'main' is at commit 11a28d32992d9888234c2ea3a630a52733a48842

With this combination, the code running inside of the :stable image is reading the local checkout to parse the kai/config.toml and its crashing as I suspect we changed structure of kai/config.toml

Error from podman compose up

kai-1     |   File "/kai/kai/server.py", line 265, in app
kai-1     |     config = KaiConfig.model_validate_filepath(
kai-1     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
kai-1     |   File "/kai/kai/models/kai_config.py", line 125, in model_validate_filepath
kai-1     |     return KaiConfig.model_validate(model_dict)
kai-1     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
kai-1     |   File "/opt/app-root/lib64/python3.12/site-packages/pydantic/main.py", line 551, in model_validate
kai-1     |     return cls.__pydantic_validator__.validate_python(
kai-1     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
kai-1     | pydantic_core._pydantic_core.ValidationError: 1 validation error for KaiConfig
kai-1     | incident_store
kai-1     |    pydantic_core._pydantic_core.ValidationError: 1 validation error for KaiConfig
kai-1     |     For further information visit https://errors.pydantic.dev/2.7/v/union_tag_not_found

https://gist.github.com/jwmatthews/2619140e479c4029b5e90d9639d41a68

The workaround for now is:

This problem will fade away when we bump the stable tag to match main, yet there is potential for it to reoccur as long as we allow a relationship of the container image reading local disk for kai/config.toml... in theory the config file does not change often so the problem isn't expected to occur a lot, but its a potential breakage we may want to isolate.

jwmatthews commented 2 weeks ago

We plan to address this in https://github.com/konveyor/kai/pull/320

The idea is that most settings will be overridden via environment variables, if the user wants/needs to make config settings, they may copy the build/config_example.toml to build/config.toml and edit what they need and this will be used and take precedence from podman compose up.