Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def _construct_from_dict(self, data: dict[str, Any]) -> Optional[Config]: | ||
| filtered: dict[str, Any] = {} | ||
| allowed_top = {field.name for field in fields(Config)} | ||
| for key, value in data.items(): | ||
| if key in allowed_top: | ||
| filtered[key] = value | ||
|
|
||
| for section, schema in ( | ||
| ("llm", LLMConfig), | ||
| ("prompt", PromptConfig), | ||
| ("database", DatabaseConfig), | ||
| ("evaluator", EvaluatorConfig), | ||
| ): | ||
| section_data = filtered.get(section) | ||
| if isinstance(section_data, dict): | ||
| allowed_fields = {field.name for field in fields(schema)} | ||
| filtered[section] = { | ||
| name: section_data[name] | ||
| for name in allowed_fields | ||
| if name in section_data |
There was a problem hiding this comment.
Filter YAML using pydantic model_fields, not dataclasses.fields
The new _construct_from_dict builds allowed_top and section field sets via dataclasses.fields(Config) and the same for LLMConfig, PromptConfig, etc. These types are pydantic BaseModels (the surrounding code already relies on Config.model_validate), so dataclasses.fields() raises TypeError: must be called with a dataclass type or instance. As a result the fallback loader now crashes whenever load_config() fails—which is exactly when this path is exercised—so heavy hitter workflows without an API key cannot load at all. Use pydantic’s model_fields (or another safe method) to enumerate allowed keys instead of dataclasses.fields.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
To use Codex here, create an environment for this repo.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_6900a73460c8833085587f41b9dacefa