Skip to content

Conversation

@bosd
Copy link
Member

@bosd bosd commented Sep 28, 2025

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @bosd, 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 reliability and debugging capabilities of the data import process. It addresses a critical issue with Odoo XML ID handling by refining the sanitization logic and ensures that the import mechanism reacts appropriately to different types of Odoo server responses, preventing silent failures and providing clearer insights into import operations.

Highlights

  • XML ID Sanitization: The to_xmlid utility function has been updated to correctly preserve dot ('.') characters, which are essential for Odoo's 'module.identifier' XML ID format, while still sanitizing other invalid characters like spaces, commas, newlines, and pipes.
  • Robust ID Handling in Imports: Data import logic now includes a sanitization step for 'id' column values, converting them to valid Odoo XML IDs before submission to prevent constraint violations during the loading process.
  • Enhanced Error Reporting: The import process now provides more detailed logging for exceptions during file reading and differentiates between Odoo server errors, warnings, and informational messages. Critical 'error' messages from Odoo will now immediately halt processing by raising a ValueError.
  • Improved Debugging Logs: Extensive debug logging has been added around the model.load call, including previews of sanitized data with truncation for large base64 fields, and detailed information about the Odoo load response.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces fixes for O2M ID field handling and improves import reliability. The changes include more robust error handling, sanitization of XML IDs to prevent constraint violations, and more detailed logging for easier debugging. My review focuses on improving code style and performance. I've suggested moving local imports to the top of the file for better maintainability and performance, and optimizing a string replacement function.

log.error(f"Failed to read file {file_path}: {e}")
log.error(f"Exception type: {type(e).__name__}")
log.error(f"Exception args: {e.args}")
import traceback

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency and to follow Python best practices (PEP 8), imports should be placed at the top of the file. Please move import traceback to the top of src/odoo_data_flow/import_threaded.py.

@bosd bosd force-pushed the clean-enhancement-commits branch 3 times, most recently from 624c213 to 5d8903f Compare September 28, 2025 11:44
bosd added 2 commits September 28, 2025 13:55
- Fix critical bug in to_xmlid function: Preserve dots in XML IDs for Odoo format
- Remove '.' from character replacements to maintain module.identifier format
- Fix syntax error in to_xmlid function docstring with proper triple quote escaping
- Enhance batch load debugging with detailed record creation verification
- Add comprehensive error logging for XML ID constraint violations and validation errors
- Improve exception handling to capture failures in fail files instead of aborting
- Add enhanced debugging for load response analysis and record creation counts
- Prevent large base64 data from flooding logs with smart truncation
- Fix ir.model.relation field validation errors with proper error handling
- Gracefully handle Odoo server internal errors during relational imports
This addresses all critical issues preventing successful O2M ID field imports:
1. XML ID constraint violations that were blocking record creation
2. Dot removal in XML IDs that was corrupting module.identifier format
3. Silent failures that were preventing proper error reporting
4. Debugging gaps that made troubleshooting difficult

The enhancement now successfully handles direct database IDs in /id suffixed fields
while maintaining compatibility with existing XML ID functionality.
@bosd bosd force-pushed the clean-enhancement-commits branch from 5d8903f to a5074ab Compare September 28, 2025 11:55
@bosd
Copy link
Member Author

bosd commented Sep 28, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several valuable improvements to the data import process, focusing on reliability and debuggability. Key changes include correcting the to_xmlid function to preserve Odoo's external ID format, adding extensive debug logging, and making the id_map creation more type-safe. The error handling for the load operation is also enhanced to differentiate between warnings and fatal errors. While these are great enhancements, I've identified a critical bug in the new ID sanitization logic that could cause issues when columns are ignored during import. I've also found a block of duplicated code that should be removed. Please see my detailed comments.

Comment on lines +835 to 839
# Check for any Odoo server errors in the response that should
# halt processing
if res.get("messages"):
for message in res["messages"]:
msg_type = message.get("type", "unknown")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This block of code, which checks for messages in the response, appears to be a duplicate. A more complete version of this logic already exists earlier in the function (lines 789-801), which properly handles different message types (error, warning, info) and raises an exception for fatal errors. This duplicated block is incomplete and redundant. It should be removed to avoid confusion and potential issues.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gemini-code-assist can you turn this into a code suggestion? #

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct! This block of code is indeed a duplicate and should be removed. The more comprehensive error handling logic is already present earlier in the function (lines 789-801).

Here's a code suggestion to remove the redundant block:

@bosd bosd force-pushed the clean-enhancement-commits branch from 84923e6 to cd7337c Compare September 28, 2025 12:38
@bosd bosd merged commit 900125e into master Sep 28, 2025
21 of 22 checks passed
@bosd bosd deleted the clean-enhancement-commits branch September 28, 2025 19:04
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