princenyeche / jiraone

A REST API Implementation to Jira Cloud APIs for creating reports and for performing other Jira queries.
https://jiraone.readthedocs.io
MIT License
25 stars 11 forks source link

Getting JiraOneError: The `limit` argument is invalid, as it does not exist in the list of accepted keyword arguments. #142

Closed felixmarch closed 2 months ago

felixmarch commented 2 months ago

Hello Prince,

As per release notes in v0.8.1 there is new function for argument validation called validate_argument_name.

I am trying to call jiraone.issue_export() with parameter limit as follows: dt = jiraone.issue_export(jql='project = DT AND updated >= %s ORDER BY key DESC' % duration, limit=9999999999, final_file="dt_csvfile")

limit is a valid argument as per doc in https://jiraone.readthedocs.io/en/latest/apis.html#jiraone.access.EndPoints.issue_export however, in the execution, I am getting this error:

Traceback (most recent call last):
  File "/opt/jira/retrieve_jira_csv.py", line 180, in <module>
    start_looping()
  File "/opt/jira/retrieve_jira_csv.py", line 173, in start_looping
    process()
  File "/opt/jira/retrieve_jira_csv.py", line 167, in process
    export_jira_to_csv()
  File "/opt/jira/retrieve_jira_csv.py", line 136, in export_jira_to_csv
    dt = jiraone.issue_export(jql='project = DT AND updated >= %s ORDER BY key DESC' % duration, limit=9999999999, final_file="dt_csvfile")
  File "/usr/local/lib/python3.9/site-packages/jiraone/reporting.py", line 3177, in export_issues
    validate_argument_name(name_keys, valid_kwargs)
  File "/usr/local/lib/python3.9/site-packages/jiraone/utils.py", line 335, in validate_argument_name
    raise JiraOneErrors(
jiraone.exceptions.JiraOneErrors: <JiraOneError: The `limit` argument is invalid, as it does not exist in the list of accepted keyword arguments.>

Can you please advice if I miss something in this new version? If I revert it back to version 0.7.9, the method above is running fine with that old version.

Thanks.

princenyeche commented 2 months ago

Hey @felixmarch

You are calling two different objects in your description. The issue_export here refers to a simple form of CSV extraction in its raw state, which doesn't do any object mapping or formatting. It is different when you call jiraone.issue_export as that refers to the function you're expecting to use and that function, doesn't have a limit argument. I never introduced the limit argument because the jiraone.issue_export function performs mapping and formatting of the data into a single CSV file. Typically, you don't need an upper limit as the function will extract everything based on JQL no matter how many issues exist within the Jira site. The page argument becomes useful when you want to split the CSV file so it doesn't become too large.

felixmarch commented 2 months ago

Hi @princenyeche,

Thank you for the explanation, I will remove the limit param accordingly then. ☺️ It would be nice if this jiraone.issue_export function can be documented in the API doc as well

Thanks for the great tool.

princenyeche commented 2 months ago

All function or method have their documentation. You can view the API here issue_export which is referring to the same object PROJECT.export_issues to know the various arguments available.

felixmarch commented 2 months ago

Thanks, but the link you provided is export_issues, not issue_export.

And in that page, it doesn't say anything about export_issues referring to the same object issue_export or vice versa.

For programmer who just relies on the doc, it would be good to have few more words on it for better clarities on the issue_export vs export_issues :blush:

princenyeche commented 2 months ago

Both objects are the same, jiraone.issue_export is equivalent to PROJECT.export_issues [code line] and you can use either one and get the same result. I do object referencing within jiraone to make accessing some objects easier (especially when I need it accessible from anywhere) and I never thought of it that way but for clarity, I can add more info in my next update that mentions the relationship somewhere within the docs. Thanks for the feedback and I'm glad that the docs are useful to users, as I'm always trying to improve how I write them.