Skip to content

save_network: paper_title/title fallback can produce zero-length vector #263

@seanthimons

Description

@seanthimons

Source: PR #262 review (round 1)
Severity: LOW (pre-existing)
File: R/db.R:1753

In save_network(), the title column is constructed as:

title = as.character(nodes_df$paper_title %||% nodes_df$title)

If a nodes_df has neither paper_title nor title column, both return NULL, and as.character(NULL) produces character(0) — a zero-length vector. This would cause the same rapi_bind: Bind parameter values need to have the same length error fixed in PR #262.

Currently safe because all code paths provide one of these columns, but it's the same fragile %||% pattern that PR #262 fixes for is_overlap/community.

Suggested fix: Use the same defensive pattern as the hotfix:

title = as.character(if (!is.null(nodes_df$paper_title)) nodes_df$paper_title
                     else if (!is.null(nodes_df$title)) nodes_df$title
                     else rep(NA_character_, nrow(nodes_df)))

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions