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".
| @router.post("/templates", response_model=FormTemplateRead, status_code=status.HTTP_201_CREATED) | ||
| def create_template(template_in: FormTemplateCreate, db: Session = Depends(get_db)) -> FormTemplate: | ||
| template = FormTemplate(**template_in.model_dump(by_alias=True)) | ||
| db.add(template) | ||
| db.commit() |
There was a problem hiding this comment.
Convert template field models before persisting JSON
The POST handler for /templates instantiates FormTemplate directly from the incoming payload and persists it, but FormTemplate.fields is a list[FieldDefinition] backed by a JSON column. Committing a model that still contains FieldDefinition instances causes SQLAlchemy to run json.dumps on pydantic objects and raise TypeError: Object of type FieldDefinition is not JSON serializable, so template creation fails for all requests. The fields need to be converted to plain dicts (or run through jsonable_encoder) before storing them in the JSON column.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68f39bdae85883248de1cf11f6de994a