bigrquery icon indicating copy to clipboard operation
bigrquery copied to clipboard

Error in bq_table_upload

Open selesnow opened this issue 1 year ago • 5 comments

Hello, until today the code worked correctly, I give an example of the code that writes data to the database below:

bq_table(project = "choice31",
         dataset = "bi_data",
         table   = "wfp_transactions_last_loading") %>%
  bq_table_upload(values = transactions,
                  create_disposition = "CREATE_IF_NEEDED",
                  write_disposition = "WRITE_TRUNCATE")

Since today I get the error:

Error in `fun(..., .envir = .envir)`:
! Could not evaluate cli `{}` expression: `margin:0;padding:0`.
Caused by error in `eval(expr, envir = envir)`:
! object 'margin' not found
Type .Last.error to see the more details.

I installed the latest versions of the bigrquery and cli packages but the error did not go away.

Traceback:

---
Backtrace:
 1. bq_table(project = "choice31", dataset = "bi_data", table = "wfp_transactions_last_loading") %>% ...
 2. bigrquery::bq_table_upload(., values = transactions, create_disposition = "CREATE_IF_NEEDED", ...
 3. bigrquery::bq_job_wait(job, quiet = quiet)
 4. base::tryCatch(bq_job_status(x), bigrquery_http_503 = function(err) NULL)
 5. base::tryCatchList(expr, classes, parentenv, handlers)
 6. base::tryCatchOne(expr, names, parentenv, handlers[[1L]])
 7. base::doTryCatch(return(expr), name, parentenv, handler)
 8. bigrquery::bq_job_status(x)
 9. bigrquery::bq_job_meta(x, "status")
10. bigrquery:::bq_get(bq_path(x$project, jobs = x$job), query = list(location = x$location, ...
11. bigrquery:::process_request(req, raw = raw)
12. bigrquery:::bq_check_response(status = status, type = type, content = content, ...
13. bigrquery:::gargle_abort(reason = NULL, message = message, status = status, ...
14. cli::cli_abort(message, class = class, call = call)
15. cli:::vcapply(message, format_inline, .envir = .envir)
16. base::vapply(X, FUN, FUN.VALUE = character(1), ..., USE.NAMES = USE.NAMES)
17. local FUN(X[[i]], ...)
18. cli::cli_fmt(fun(..., .envir = .envir), collapse = collapse, strip_newline = TRUE)
19. cli:::cli__rec(expr)
20. local fun(..., .envir = .envir)
21. cli:::cli__message("inline_text", list(text = glue_cmd(..., .envir = .envir, ...
22. "id" %in% names(args)
23. cli:::glue_cmd(..., .envir = .envir, .call = sys.call(), .trim = FALSE)
24. cli:::glue(str, .envir = .envir, .transformer = transformer, .cli = TRUE, ...
25. (function (expr) ...
26. .transformer(expr, .envir) %||% character()
27. local .transformer(expr, .envir)
28. eval(expr, envir = envir) %??% cli_error(call. = caller, "Could not evaluate cli {.code {{}}} expression:\n           {.code {abbrev(code, 20)}...
29. cli:::chain_error(expr, err, srcref = utils::getSrcref(sys.call()))
30. | base::withCallingHandlers({ ...
31. base::eval(expr, envir = envir)
32. base::eval(expr, envir = envir)
33. base::.handleSimpleError(function (e) ...
34. | local h(simpleError(msg, call))
35. | cli:::throw_error(err, parent = e)

Can you help me?

selesnow avatar Oct 16 '24 07:10 selesnow

Unfortunately this error happens while bigrquery is trying to throw another error, the real error. Try debugging the real error, that is coming from gargle:::gargle_abort(). E.g. try to put a breakpoint there:

debug(gargle:::gargle_abort)

and then see if you can find out the issue from the objects there. Or at bigrquery:::bq_check_response().

gaborcsardi avatar Oct 16 '24 13:10 gaborcsardi

Look, i get next error in HTML format, and this error cant parsed by bigrquery

selesnow avatar Oct 16 '24 14:10 selesnow

I intercepted the response in the bq_post() function, and saved it to the rec.rds file, attached it to the message as a rec.zip file, just change the extension from zip to rds and you can improve the error parser

req.zip

selesnow avatar Oct 16 '24 14:10 selesnow

content(req, as = 'text')

This text

<!DOCTYPE html>\n<html lang=en>\n  <meta charset=utf-8>\n  <meta name=viewport content=\"initial-scale=1, minimum-scale=1, width=device-width\">\n  <title>Error 403 (Forbidden)!!1</title>\n  <style>\n    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}\n  </style>\n  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>\n  <p><b>403.</b> <ins>That’s an error.</ins>\n  <p>Your client does not have permission to get URL <code>/bigquery/v2/projects/netpeak-1079/jobs/</code> from this server.  <ins>That’s all we know.</ins>\n

selesnow avatar Oct 16 '24 14:10 selesnow

@selesnow hopefully that error gives you enough info to debug the problem for now, and we'll improve the error message in the next bigrquery release.

hadley avatar Oct 16 '24 18:10 hadley