Skip to content

Fix O*NET API response handling: remove non-existent relevance_score, handle NULL columns#5

Merged
farach merged 3 commits intomainfrom
copilot/fix-onet-api-bugs
Jan 15, 2026
Merged

Fix O*NET API response handling: remove non-existent relevance_score, handle NULL columns#5
farach merged 3 commits intomainfrom
copilot/fix-onet-api-bugs

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 15, 2026

The O*NET API returns different data than documented. The onet_search() function included a relevance_score column that the API never returns (always NA), and as_onet_tibble() failed when the API returned NULL for optional columns like not_relevant in skills data.

Changes

  • Remove relevance_score from onet_search() - API doesn't provide this field

    • Updated return schema from code, title, relevance_score to code, title
    • Updated docs, README, and vignette examples
  • Handle NULL columns in as_onet_tibble() - Convert NULL values to NA before tibble conversion

    • Prevents as_tibble() errors when API response contains NULL columns
    • Added test coverage for NULL column handling
  • Path segment handling - Already correctly implemented in PR Separate path segments from query parameters in API request construction #4, no changes needed

    • onet_request() properly uses req_url_path_append() for path segments
    • Query parameters correctly use req_url_query()

Example

# Before: relevance_score always NA
onet_search("software developer")
#> # A tibble: 20 × 3
#>    code       title               relevance_score
#>  1 15-1252.00 Software Developers              NA

# After: clean two-column output
onet_search("software developer")
#> # A tibble: 20 × 2
#>    code       title
#>  1 15-1252.00 Software Developers

# NULL handling now works
as_onet_tibble(list(code = "15-1252.00", not_relevant = NULL))
#> Previously errored, now converts NULL to NA

No breaking changes to function signatures.

Original prompt

Fix O*NET API bugs in farach/onet2r:

  • Update the request builder so path segments are appended correctly instead of being passed as query params. Current calls like onet_request("online/occupations", code, "summary") are generating query parameters and returning 404. Adjust onet_request() (and any helpers if needed) to support path segments and still allow query parameters.
  • Fix onet_search() to drop the relevance_score column entirely (it is not returned by the API and always NA). Update docs/tests accordingly.
  • Fix onet_table()/as_onet_tibble() conversion to handle NULL columns from API responses (e.g., not_relevant being NULL in skills data) so as_tibble() does not error; replace NULL columns with NA vectors or otherwise coerce safely.

Ensure tidyverse-friendly behavior, update any affected unit tests or documentation, and keep function signatures stable unless necessary.

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 15, 2026 11:21
Co-authored-by: farach <1520139+farach@users.noreply.github.com>
Co-authored-by: farach <1520139+farach@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix O*NET API bugs in onet2r Fix O*NET API response handling: remove non-existent relevance_score, handle NULL columns Jan 15, 2026
Copilot AI requested a review from farach January 15, 2026 11:25
Copy link
Copy Markdown
Owner

@farach farach left a comment

Choose a reason for hiding this comment

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

Great

@farach farach marked this pull request as ready for review January 15, 2026 11:43
@farach farach merged commit 5c22106 into main Jan 15, 2026
@farach farach deleted the copilot/fix-onet-api-bugs branch January 15, 2026 11:43
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