fix: Fix the RecordNotInsert error caused by ON CONFLICT DO NOTHING in cla_storage.#2022
Open
231220075 wants to merge 1 commit intoweb3infra-foundation:mainfrom
Open
fix: Fix the RecordNotInsert error caused by ON CONFLICT DO NOTHING in cla_storage.#2022231220075 wants to merge 1 commit intoweb3infra-foundation:mainfrom
231220075 wants to merge 1 commit intoweb3infra-foundation:mainfrom
Conversation
Contributor
231220075
commented
Mar 14, 2026
- In the CLA storage layer, resolve the insert error caused by ON CONFLICT DO NOTHING.
- Perform an additional check and error reporting after the insert operation.
Member
|
@codex review |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes CLA status writes that can fail under SeaORM ON CONFLICT DO NOTHING semantics (surfacing as DbErr::RecordNotInserted), and adds a post-write verification to ensure sign() actually results in a signed state.
Changes:
- Treat
DbErr::RecordNotInsertedfrominsert(...).on_conflict(...).do_nothing()as an expected no-op instead of a hard failure. - After
sign(), re-read the row and return an error if the CLA status is still unsigned.
jupiter/src/storage/cla_storage.rs
Outdated
Comment on lines
+113
to
+115
| return Err(MegaError::Other( | ||
| "CLA status still unsigned after sign operation".to_string(), | ||
| )); |
jupiter/src/storage/cla_storage.rs
Outdated
Comment on lines
+48
to
+59
| match cla_sign_status::Entity::insert(model) | ||
| .on_conflict( | ||
| OnConflict::column(cla_sign_status::Column::Username) | ||
| .do_nothing() | ||
| .to_owned(), | ||
| ) | ||
| .exec(self.get_connection()) | ||
| .await?; | ||
| .await | ||
| { | ||
| Ok(_) | Err(DbErr::RecordNotInserted) => {} | ||
| Err(e) => return Err(e.into()), | ||
| } |
jupiter/src/storage/cla_storage.rs
Outdated
Comment on lines
+85
to
+96
| match cla_sign_status::Entity::insert(active_model) | ||
| .on_conflict( | ||
| OnConflict::column(cla_sign_status::Column::Username) | ||
| .do_nothing() | ||
| .to_owned(), | ||
| ) | ||
| .exec(self.get_connection()) | ||
| .await?; | ||
| .await | ||
| { | ||
| Ok(_) | Err(DbErr::RecordNotInserted) => {} | ||
| Err(e) => return Err(e.into()), | ||
| } |
|
Codex Review: Didn't find any major issues. 🚀 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…n cla_storage. Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn> code review Signed-off-by: Ruizhi Huang <231220075@smail.nju.edu.cn>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.