Fix Memgraph parameter serialization error for cited_by_count_date#42
Fix Memgraph parameter serialization error for cited_by_count_date#42ssheikholeslami merged 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes Memgraph parameter serialization failures by aligning the cited_by_count_date field type with actual usage (year integer) so the Neo4j driver doesn’t send a Bolt temporal parameter that Memgraph can’t deserialize.
Changes:
- Change
AnonymousArticle.cited_by_count_datefromOptional[datetime]toOptional[int].
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| openalex: Optional[str] = None | ||
| cited_by_count: Optional[int] = None | ||
| cited_by_count_date: Optional[datetime] = None | ||
| cited_by_count_date: Optional[int] = None |
There was a problem hiding this comment.
cited_by_count_date now stores a year integer rather than a full date/time, so the field name is misleading and can cause confusion for future readers/DB consumers. Consider renaming it to something like cited_by_count_year (and, if you need to keep the persisted property name stable, use a Pydantic alias or a clear field description).
| cited_by_count_date: Optional[int] = None | |
| cited_by_count_year: Optional[int] = Field( | |
| default=None, | |
| alias="cited_by_count_date", | |
| description="Year associated with cited_by_count; persisted as 'cited_by_count_date'.", | |
| ) |
willu47
left a comment
There was a problem hiding this comment.
Looks good @ssheikholeslami
I'd recommend changing the name as the CoPilot bot has recommended - cited_by_count_date should really be cited_by_count_year. However, this may have downstream effects on the research_index API and the memgraph database schema.
If you want to leave it for later, I suggest creating an issue and merging this as is.
Summary
cited_by_count_datetype fromOptional[datetime]toOptional[int]inAnonymousArticlemodelProblem
When ingesting DOIs, the
Article.save()query fails with:Memgraph.ExecutionException - Couldn't read parameters!The root cause is a type mismatch:
parser.pypassesdatetime.now().yearwhich is anint(e.g. 2026)cited_by_count_date: Optional[datetime]datetimeobject (interpreting it as a Unix timestamp)Fix
Changed the type annotation in
models.pytoOptional[int], which matches the actual usage. The field only stores the year the citation count was fetched, not a full datetime.Test plan
research_index list_of_dois.csv -l 5— DOIs ingested without errorsCouldn't read parameters!errorshatch test— all tests pass