openanalytics / redmineR

R client for redmine
Other
13 stars 7 forks source link

redmine_users() throws error #6

Open WurmPeter opened 1 year ago

WurmPeter commented 1 year ago

Hello,

I found this great package today, thanks :) Is it still maintained?

We are running a local redmine installation in version 5.0.3.stable. When I run redmineR::redmine_users() I get this error:

[17:17:01] ERROR h() replacement element 9 has 38 rows, need 42
Error in `[<-.data.frame`(`*tmp*`, atomicCols, value = list(id = c(33L,  : 
  replacement element 9 has 38 rows, need 42
mnazarov commented 1 year ago

Hello, I would say it is in a 'sleeping' state, but nevertheless we can try to help. Unfortunately I can't reproduce the error you are getting, it appears to be happening at the moment of merging together response data from the users. Do you happen to have custom fields for users?

If you are comfortable with debugging, I suggest you run

debugonce(redmineR:::redmine_get_all_pages)
redmineR::redmine_users()

and then follow the code line be line - from the error message it appears to fail at the line res_df[atomicCols] <- lapply(res_df[atomicCols], unlist) - so hopefully you would see what exactly is failing. If you could then share your findings, we will use that to improve the package.

WurmPeter commented 1 year ago

Hello,

Thanks for trying to help. I think I have successfully debugged this problem. First, we do not use custom fields for users.

So by debugging I stopped at this line res_df[atomicCols] <- lapply(res_df[atomicCols], unlist) and noticed that some rows have NULLs in column "last_login_on". So I manually set them to "2021-04-20T13:12:51Z" and then it worked.

So that line should be changed to handle NULLs well. Are you able to fix that? Maybe going through all cells and replace NULLs with NAs (seem to be fine) before that step via res_df <- res_df %>% dplyr::replace(.=="NULL", NA)?

EDIT: Had the same issue with redmineR::redmine_custom_fields() and redmineR::redmine_issues(assigned_to_id = 17) and replacing the NULLs as described above worked there, too.

mnazarov commented 1 year ago

Thanks for debugging. I would appreciate if you could share (a part of) your data in res_df to understand it better. Are the NULLs that you mention actually string "NULL"s (as in your replace call) or actual NULLs?

WurmPeter commented 1 year ago

I don't know what is the best way to share that data.

I can tell you that in RStudio in the environment it shows NULL, not "NULL": redmineR_bug_environment (I had to black out sensitive information)

(btw: It seems that the NULLs in column "twofa_scheme" do no harm - maybe because all rows contain NULL?)

WurmPeter commented 1 year ago

Hello,

Do you think this is a bad solution?