Skip to content

Fix error w/ misplaced arg + call in validate_crs() - #102

Merged
JosiahParry merged 3 commits into
R-ArcGIS:mainfrom
elipousson:fix-capture_message
Oct 15, 2026
Merged

JosiahParry merged 3 commits into
R-ArcGIS:mainfrom
elipousson:fix-capture_message

Conversation

@elipousson

Copy link
Copy Markdown
Contributor

I don't have a reprex that works from a source URL because I ran into this while getting transient errors on a really big request but I put together a smaller reprex that I'm hoping works:

library(arcgisutils)
#> 
#> Attaching package: 'arcgisutils'
#> The following object is masked from 'package:base':
#> 
#>     %||%

# A typical ArcGIS REST error response: `details` is an empty JSON array
error_json <- '{"error": {"code": 504, "message": "Your request has timed out.", "details": []}}'

# Parsed without simplification, the empty array becomes an empty list
resp <- jsonlite::fromJSON(error_json, simplifyVector = FALSE)
str(resp$error$details)
#>  list()

# `c(<chr>, i = list())` returns a list instead of a character vector...
str(arcgisutils:::capture_message(resp))
#> List of 1
#>  $ : chr "Status code: 504\nError: Your request has timed out."

# ...so the original error message is lost and rlang::abort() errors instead
detect_errors(resp)
#> Error in `rlang::abort()`:
#> ! `message` must be a character vector, not a list.

# Using `unlist()` keeps the message a character vector
str(c("Status code: 504", i = unlist(resp$error$details)))
#>  chr "Status code: 504"

Created on 2026-10-15 with reprex v2.1.1

Thanks as always!

Also allow doubles mis-read as integers to not trigger erro
@elipousson

Copy link
Copy Markdown
Contributor Author

I actually misdiagnosed this issue. It was actually a misplaced arg and call argument inside of validate_crs that was causing the issue, I think. The first commit could probably be reverted.

@elipousson elipousson changed the title Fix error where error details are a list Fix error w/ misplaced arg + call in validate_crs() Oct 15, 2026
@JosiahParry

Copy link
Copy Markdown
Collaborator

@elipousson would you mind adding another test here?

@JosiahParry

Copy link
Copy Markdown
Collaborator

Also note that we do not use jsonlite so if the expectation is against the structure of jsonlite and not RcppSimdJson that may be a bug

@elipousson

Copy link
Copy Markdown
Contributor Author

@JosiahParry Sure. Do you want me to revert the change to detect_errors also?

@JosiahParry

Copy link
Copy Markdown
Collaborator

Hm. Is there a repro to get a message where the error is > length 1 message? I've not encountered it.

@elipousson

Copy link
Copy Markdown
Contributor Author

No, but it is the same error message is just what you get from validate_crs with the misplaced arg and call arguments. I'll revert it and add the tests.

Add tests for validate_crs

Also revert change to capture_message
@JosiahParry
JosiahParry merged commit ff9f398 into R-ArcGIS:main Oct 15, 2026
5 of 7 checks passed
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