Skip to content

feat(Harvest): Implement the function to obtain anchor author#117

Merged
CJBshuosi merged 1 commit into
jerry609:masterfrom
CJBshuosi:master
Feb 13, 2026
Merged

feat(Harvest): Implement the function to obtain anchor author#117
CJBshuosi merged 1 commit into
jerry609:masterfrom
CJBshuosi:master

Conversation

@CJBshuosi

@CJBshuosi CJBshuosi commented Feb 13, 2026

Copy link
Copy Markdown
Collaborator

Closes #116

截屏2026-02-13 20 42 00

Summary by CodeRabbit

  • New Features

    • Added automatic synchronization of author-paper associations when papers are stored or updated, ensuring author data remains consistent.
  • Bug Fixes

    • Implemented error handling for author synchronization to prevent failures in the paper storage process.

Closes jerry609#116

Signed-off-by: LIU BOYU <oor2020@163.com>
@vercel

vercel Bot commented Feb 13, 2026

Copy link
Copy Markdown

@CJBshuosi is attempting to deploy a commit to the Jerry's projects Team on Vercel.

A member of the Team first needs to authorize it.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @CJBshuosi, 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 introduces a significant enhancement to the PaperStore by integrating robust author management capabilities. It enables the system to properly link authors to papers during the data harvesting process, ensuring that author information is consistently stored and associated with the relevant research papers. This change improves data integrity and expands the functionality for managing bibliographic data.

Highlights

  • Author Management Integration: Integrated the AuthorStore into the PaperStore to handle author-related operations, specifically linking authors to papers.
  • PaperStore Initialization: Modified the PaperStore constructor to initialize an AuthorStore instance, making author management capabilities available.
  • Author Linking during Paper Upsert: Enhanced the upsert_paper method to call _author_store.replace_paper_authors, ensuring that authors are correctly associated with papers upon creation or update.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/paperbot/infrastructure/stores/paper_store.py
    • Imported AuthorStore for managing author data.
    • Instantiated AuthorStore in the PaperStore constructor.
    • Added logic to link authors to papers using AuthorStore during upsert_paper, including error handling.
Activity
  • No human activity has been recorded for this pull request yet.
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.

@coderabbitai

coderabbitai Bot commented Feb 13, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The pull request adds author synchronization to the paper storage workflow. After a paper is created or updated, the system now attempts to persist paper-author associations through an AuthorStore instance with graceful error handling.

Changes

Cohort / File(s) Summary
Author-Paper Association
src/paperbot/infrastructure/stores/paper_store.py
Added AuthorStore dependency initialization in __init__ and integrated replace_paper_authors() call in upsert_paper() to persist paper-author relationships with warning-level error handling on sync failure.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A paper finds its author's name,
No more lost in the database game!
With AuthorStore linked so tight,
Each author's credit shines so bright. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title refers to implementing an anchor author function but the changes only add author-paper association persistence to PaperStore, not anchor author retrieval logic. Update the title to reflect the actual changes, such as 'feat(Harvest): Add author-paper association persistence in PaperStore' or clarify if anchor author retrieval logic is in a separate commit.
Linked Issues check ⚠️ Warning The PR implements author-paper association persistence but does not include the API endpoint or retrieval logic needed to obtain and display anchor authors on the Dashboard as required by issue #116. Add the API endpoint and query logic to retrieve anchor authors from saved papers and display them on the Dashboard as specified in issue #116.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Out of Scope Changes check ✅ Passed All changes are within scope as they support the author management infrastructure needed for the anchor author feature, though the API retrieval layer is incomplete.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into master

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/paperbot/infrastructure/stores/paper_store.py (1)

466-513: ⚠️ Potential issue | 🟠 Major

upsert_papers_batch does not sync authors to the paper_authors table.

The upsert_paper method syncs authors via replace_paper_authors (lines 274–280), but upsert_papers_batch skips this step entirely. Papers ingested through upsert_papers_batch will have authors_json populated on PaperModel but no corresponding rows in the paper_authors join table. If anchor author discovery queries paper_authors, these papers will be invisible to that feature.

Add author sync after the batch commit by iterating over the flushed papers and calling replace_paper_authors for each, matching the pattern in upsert_paper.

🧹 Nitpick comments (1)
src/paperbot/infrastructure/stores/paper_store.py (1)

104-104: Consider sharing the SessionProvider with AuthorStore instead of creating a duplicate engine.

Both PaperStore and the embedded AuthorStore instantiate their own SessionProvider against the same db_url, which means two separate connection pools to the same database. If AuthorStore can accept an existing SessionProvider or engine, that would reduce resource usage.

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

Copy link
Copy Markdown

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 implements the functionality to sync author information when a paper is created or updated. A medium-severity vulnerability was identified related to the logging of sensitive information in exception handlers, which could lead to potential data leaks. Additionally, the error handling should be refined to catch more specific exceptions instead of a general Exception to improve robustness and maintainability.

Comment on lines +282 to +285
Logger.warning(
f"Failed to sync paper authors for paper {row.id}: {e}",
file=LogFiles.HARVEST,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security-medium medium

The application logs the entire exception object e when an error occurs while syncing paper authors. The string representation of a database exception can include sensitive information, such as the full SQL query with its parameters or other internal details. Logging such raw exception data can lead to the exposure of sensitive user information (e.g., author names, IDs) in the log files, which may not have the same security controls as the primary database.

Suggested change
Logger.warning(
f"Failed to sync paper authors for paper {row.id}: {e}",
file=LogFiles.HARVEST,
)
Logger.warning(
f"Failed to sync paper authors for paper {row.id}. Reason: An unexpected error occurred.",
file=LogFiles.HARVEST,
)

PaperModel,
)
from paperbot.infrastructure.stores.sqlalchemy_db import SessionProvider, get_db_url
from paperbot.infrastructure.stores.author_store import AuthorStore

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To handle database-specific errors gracefully when syncing authors, let's import SQLAlchemyError. This will be used in the try...except block below.

Suggested change
from paperbot.infrastructure.stores.author_store import AuthorStore
from paperbot.infrastructure.stores.author_store import AuthorStore
from sqlalchemy.exc import SQLAlchemyError

paper_id=int(row.id),
authors=authors,
)
except Exception as e:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using a broad except Exception can mask underlying issues and make debugging harder. It's better practice to catch more specific exceptions that you anticipate, like ValueError (which replace_paper_authors can raise) and database-related errors like SQLAlchemyError.

Suggested change
except Exception as e:
except (ValueError, SQLAlchemyError) as e:

@CJBshuosi
CJBshuosi merged commit f0c0537 into jerry609:master Feb 13, 2026
4 of 5 checks passed
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.

[Feature] Implement the function to obtain anchor author

1 participant