-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Summary
get_content() fails with type mismatch errors when the Connect server returns content items where some have character fields (like cluster_name, r_version, py_version, title, etc.) as character and others have them as logical/NULL. This affects multiple optional character fields, not just one.
Error Messages
Various errors depending on which field has the type mismatch:
Error in dplyr::bind_rows: Can't combine `..1$cluster_name` <character> and `..3$cluster_name` <logical>.
Error in dplyr::bind_rows: Can't combine `..1$r_version` <character> and `..2$r_version` <logical>.
Error in dplyr::bind_rows: Can't combine `..1$title` <character> and `..88$title` <logical>.
The pattern is consistent: character fields that can be NULL for certain content types are being parsed inconsistently.
Environment
- connectapi version: 0.8.0 (also affects 0.10.0)
- Connect version: 2026.03.0-dev+6-g34e1d74381
- R version: 4.5.0
- dplyr version: 1.1.4
- purrr version: 1.0.2
Root Cause
The issue occurs in the parse_connectapi() function when processing content data:
-
The Connect API returns content items where:
- Content in clusters has:
cluster_name = "cluster-name-string" - Content not in clusters has:
cluster_name = null
- Content in clusters has:
-
When R processes these:
- Character values remain character type
- NULL values become logical NA
-
parse_connectapi()usespurrr::map_df()which callsdplyr::bind_rows() -
bind_rows()fails immediately when trying to combine character and logical columns -
The
ptypedefinition (cluster_name = NA_character_) exists but is applied after parsing viaensure_columns(), so it never gets a chance to fix the types
Impact
This affects any application using get_content() when connected to a Connect server that has:
- Cluster support enabled
- A mix of content items in and out of clusters
Reproducibility
This should be reproducible by:
- Setting up a Connect server with cluster support
- Creating some content in a cluster and some outside
- Calling
get_content()via connectapi
Additional Context
The ptype.R file already defines all these fields with their correct types in the content prototype (e.g., cluster_name = NA_character_, r_version = NA_character_, etc.), showing the library authors intended these fields to be character type. The issue is that this normalization happens too late in the process - after bind_rows() has already failed.
Fields known to be affected:
cluster_name- NULL for content not in clustersr_version- NULL for non-R contentpy_version- NULL for non-Python contentquarto_version- NULL for non-Quarto contentimage_name- NULL for non-containerized contenttitle- NULL for certain content items- Potentially any other optional character field in the content schema