Skip to content

Type Mismatch Error with Multiple Character Fields #510

@marcosnav

Description

@marcosnav

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:

  1. The Connect API returns content items where:

    • Content in clusters has: cluster_name = "cluster-name-string"
    • Content not in clusters has: cluster_name = null
  2. When R processes these:

    • Character values remain character type
    • NULL values become logical NA
  3. parse_connectapi() uses purrr::map_df() which calls dplyr::bind_rows()

  4. bind_rows() fails immediately when trying to combine character and logical columns

  5. The ptype definition (cluster_name = NA_character_) exists but is applied after parsing via ensure_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:

  1. Setting up a Connect server with cluster support
  2. Creating some content in a cluster and some outside
  3. 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 clusters
  • r_version - NULL for non-R content
  • py_version - NULL for non-Python content
  • quarto_version - NULL for non-Quarto content
  • image_name - NULL for non-containerized content
  • title - NULL for certain content items
  • Potentially any other optional character field in the content schema

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions