fix(spp_api_v2_change_request): fix URL encoding, type schema endpoints, and validation#37
fix(spp_api_v2_change_request): fix URL encoding, type schema endpoints, and validation#37
Conversation
…d validation gaps - Fix pagination URLs not being URL-encoded (broken links with pipe/colon chars) - Raise ValidationError on unresolved vocabulary/partner lookups instead of silently skipping - Add detail input validation against type schema (unknown, internal, readonly fields) - Fix manifest: PATCH→PUT, add missing $request-revision and $reset endpoints - Remove unused ChangeRequestAction and ChangeRequestSearchParams schemas - Remove unnecessary hasattr check for revision_notes (always on mixin) - Add comments explaining why _do_reject/_do_request_revision are called directly - Extract shared test fixtures into tests/common.py ChangeRequestTestCase - Add tests for reject/approve wrong state, unknown fields, unresolved vocab, readonly fields
Summary of ChangesHello @jeremi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Change Request API by improving its robustness, discoverability, and usability. It addresses issues with URL encoding for references, introduces new endpoints for dynamic schema discovery, and strengthens data validation in the service layer. These changes provide a more reliable and self-documenting API, making it easier for clients to interact with Change Requests and their associated data structures. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request significantly improves the Change Request API by fixing URL encoding issues and introducing $types and $types/{code} endpoints for schema discovery. A comprehensive security audit confirmed no critical vulnerabilities were identified, and the changes adhere to secure practices including input validation and enhanced error handling. While the implementation is robust, consider improving the handling of malformed date strings and refining the API schema for greater precision.
| type: str = Field( | ||
| ..., | ||
| description="Field type (string, text, integer, float, boolean, date, datetime, selection, code, reference)", | ||
| ) |
There was a problem hiding this comment.
The type field in the FieldDefinition schema has a finite set of possible string values. To make the API schema more precise and enable stricter validation on the client and server side, it's better to use typing.Literal instead of str. This also serves as clear documentation for the allowed values.
| type: str = Field( | |
| ..., | |
| description="Field type (string, text, integer, float, boolean, date, datetime, selection, code, reference)", | |
| ) | |
| type: Literal[ | |
| "string", | |
| "text", | |
| "integer", | |
| "float", | |
| "boolean", | |
| "date", | |
| "datetime", | |
| "selection", | |
| "code", | |
| "reference", | |
| ] = Field( | |
| ..., | |
| description="Field data type", | |
| ) |
…pe schema with JSON Schema 2020-12 Add generic OdooModelSchemaBuilder that converts any Odoo model's fields to a standard JSON Schema 2020-12 document. Refactor CR type schema endpoint to return detailSchema (JSON Schema) instead of proprietary FieldDefinition objects, enabling third-party tooling (ajv, jsonschema, react-jsonschema-form) to work out of the box. Key changes: - Add spp_api_v2/services/schema_builder.py with field type mapping, vocabulary extraction, and selection choice handling - Replace FieldDefinition/VocabularyInfo pydantic models with a plain dict[str, Any] detailSchema field on ChangeRequestTypeSchema - Optimize _validate_detail_input to use direct field introspection instead of building full schema (avoids unnecessary DB queries) - Use anyOf for many2one reference types (2020-12 conformance)
…r fields Replace plain str with Literal for fields that have a known, fixed set of valid values: ChangeRequestResponse.status and ChangeRequestTypeInfo.target_type. This provides stricter validation and clearer API documentation.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 19.0 #37 +/- ##
=======================================
Coverage ? 68.82%
=======================================
Files ? 388
Lines ? 31615
Branches ? 0
=======================================
Hits ? 21760
Misses ? 9855
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
/{p1}/{p2}/{p3}) to fix URL-encoded slashes being rejected by FastAPI$typesand$types/{code}endpoints for listing CR types and their field schemasDETAIL_SKIP_FIELDSconstant and addODOO_TYPE_MAP/SKIP_FIELD_TYPESfor field schema generationcommon.py) and type schema testsTest plan
test_single_module.sh spp_api_v2_change_requestCR/2026/00001)GET /ChangeRequest/$typesreturns type listGET /ChangeRequest/$types/{code}returns field schema