Skip to content

Conversation

@jhnwllr
Copy link
Collaborator

@jhnwllr jhnwllr commented Dec 12, 2025

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for returning acceptedUsageKey and acceptedScientificName fields from the name_backbone function to handle taxonomic synonyms. When the GBIF API returns a synonym, these fields provide information about the accepted/valid name for the taxon. This addresses issue #824.

  • Extracts acceptedUsage data from the GBIF species match API v2 response
  • Adds test coverage for the new fields using a synonym example (Anastrophyllum minutum)
  • Increments package version from 3.8.4.1 to 3.8.4.2

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
R/name_backbone.r Adds processing logic to extract acceptedUsageKey and acceptedScientificName from API response
tests/testthat/test-name_backbone.r Adds test to verify the new fields are returned
tests/fixtures/name_backbone_acceptedUsageKey.yml Provides VCR cassette with API response containing synonym and acceptedUsage data
DESCRIPTION Bumps version to 3.8.4.2

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +138 to +139
expect_true("acceptedUsageKey" %in% colnames(aa))
expect_true("acceptedScientificName" %in% colnames(aa))
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The test verifies that the columns exist but doesn't check their actual values. Based on the fixture data, the test should verify that acceptedUsageKey is "2689422" and acceptedScientificName is "Sphenolobus minutus (Schreb. ex Cranz) Berggr." to ensure the function correctly extracts these values from the API response.

Copilot uses AI. Check for mistakes.
Comment on lines +266 to +268
a <- tibble::as_tibble(tt$acceptedUsage)[c("key","name")]
colnames(a)[colnames(a) == "key"] <- "acceptedUsageKey"
colnames(a)[colnames(a) == "name"] <- "acceptedScientificName"
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The acceptedUsage processing subsets only the "key" and "name" fields, which is inconsistent with how the usage object is processed (lines 231-235). The usage processing converts the entire object to a tibble and then renames specific columns. Consider following the same pattern here: convert the entire acceptedUsage object to a tibble first, then rename the columns, to maintain consistency and allow any additional fields from the API to be included.

Suggested change
a <- tibble::as_tibble(tt$acceptedUsage)[c("key","name")]
colnames(a)[colnames(a) == "key"] <- "acceptedUsageKey"
colnames(a)[colnames(a) == "name"] <- "acceptedScientificName"
a <- tibble::as_tibble(tt$acceptedUsage)
if ("key" %in% colnames(a)) colnames(a)[colnames(a) == "key"] <- "acceptedUsageKey"
if ("name" %in% colnames(a)) colnames(a)[colnames(a) == "name"] <- "acceptedScientificName"

Copilot uses AI. Check for mistakes.
@jhnwllr jhnwllr merged commit 8736b7c into master Dec 12, 2025
13 checks passed
@jhnwllr jhnwllr deleted the bugfix/acceptedusage-name-bug branch December 12, 2025 11:08
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.

2 participants