Skip to content

let Jira cloud assign a default permissionScheme if none is specified #1483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

codectl
Copy link
Contributor

@codectl codectl commented Aug 31, 2022

issue: when a permissionScheme is specified , Jira cloud raises a 500 error

@github-actions github-actions bot added the bug label Aug 31, 2022
@codectl
Copy link
Contributor Author

codectl commented Aug 31, 2022

this closes #1483

@adehad
Copy link
Contributor

adehad commented Sep 4, 2022

hmm this doesn't seem right, the Jira Cloud docs do say this is a correct parameter:
https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-projects/#api-rest-api-2-project-post

@adehad
Copy link
Contributor

adehad commented Sep 4, 2022

we should add a test for this in our cloud tests

@codectl
Copy link
Contributor Author

codectl commented Sep 4, 2022

I found this issue mentioned as well by some user:

https://community.atlassian.com/t5/Jira-questions/Using-Default-Permission-Scheme-with-Create-Project-API-causes/qaq-p/1862489

It has almost a year and the issue still persists.

@codectl
Copy link
Contributor Author

codectl commented Sep 4, 2022

The documentation says it's a valid field but it still throws a 500. We either embrace the error or we remove the field if not specified, which is what I am proposing.

The current test manager is suppressing that and other errors so the test suite does not cover that scenario:

...
            create_attempts = 6
            for _ in range(create_attempts):
                try:
                    if self.jira_admin.create_project(project_key, project_name):
                        break
                except JIRAError as e:
                    if "A project with that name already exists" not in str(e):
                        raise e

@adehad
Copy link
Contributor

adehad commented Sep 4, 2022

I don't think the test manager is suppressing this error, it only ignores if the error message is relating to the project already existing

@adehad
Copy link
Contributor

adehad commented Sep 4, 2022

Are you able to confirm the integer value the original code returns for your instance?

@codectl
Copy link
Contributor Author

codectl commented Sep 4, 2022

My simplest test is the following:

>>> j = JIRA(...)
>>> j._session.post(j._get_url("project"), data={"key": "X", "name": "XYZ", "leadAccountId": "xxx", "projectTypeKey": "software"})
<Response [201]>
>>> j._session.post(j._get_url("project"), data={"key": "X", "name": "XYZ", "leadAccountId": "xxx", "projectTypeKey": "software", "permissionScheme": 0}})
jira.exceptions.JIRAError: JiraError HTTP 500 url: https://xxx.atlassian.net/rest/api/2/project
        text: Internal server error
        
        response headers = {...}
        response text = {"errorMessages":["Internal server error"],"errors":{}}

Having the field permissionScheme on raises a 500.

@codectl
Copy link
Contributor Author

codectl commented Sep 4, 2022

Are you able to confirm the integer value the original code returns for your instance?

I am running it against Jira Cloud Platform and the permissionScheme is forced to 0 if I don't specify it - if that was the question asked.

@codectl
Copy link
Contributor Author

codectl commented Sep 4, 2022

I don't think the test manager is suppressing this error, it only ignores if the error message is relating to the project already existing

You're right , it doesn't look like it. I need more time to understand what is suppressing the 500.

codectl and others added 2 commits September 4, 2022 20:15
Co-authored-by: Adel Haddad <26027314+adehad@users.noreply.github.com>
@codectl
Copy link
Contributor Author

codectl commented Sep 4, 2022

Ok so I ran the Jira Cloud CI on my local env and it fails:

...
  File "/tmp/jira/tests/conftest.py", line 255, in _create_project
    if self.jira_admin.create_project(project_key, project_name):

which is the following line:

...
if self.jira_admin.create_project(project_key, project_name):

It begs the question of how is this not failing in this project?

I ran the test suite against API v2:

https://xxx.atlassian.net/rest/api/2

@adehad
Copy link
Contributor

adehad commented Sep 5, 2022

Do you have more details in the traceback? I also find it strange that if you are also a Jira admin that you are not able to reproduce the same behaviour

@codectl
Copy link
Contributor Author

codectl commented Sep 5, 2022

Yes full stack trace below:

ERROR    tests.conftest:conftest.py:63 JiraError HTTP 500 url: https://xxx.atlassian.net/rest/api/2/project
        text: Internal server error
        
        response headers = {...}
        response text = {"errorMessages":["Internal server error"],"errors":{}}
Traceback (most recent call last):
  File "/tmp/jira/tests/conftest.py", line 58, in setUp
    self.test_manager = JiraTestManager()
  File "/tmp/jira/tests/conftest.py", line 156, in __init__
    self.create_some_data()
  File "/tmp/jira/tests/conftest.py", line 287, in create_some_data
    self.project_a_id = self._create_project(self.project_a, self.project_a_name)
  File "/tmp/jira/tests/conftest.py", line 259, in _create_project
    raise e
  File "/tmp/jira/tests/conftest.py", line 255, in _create_project
    if self.jira_admin.create_project(project_key, project_name):
  File "/tmp/jira/jira/client.py", line 4449, in create_project
    r = self._session.post(url, data=json.dumps(payload))
  File "/tmp/jira/.tox/py39/lib/python3.9/site-packages/requests/sessions.py", line 635, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
  File "/tmp/jira/jira/resilientsession.py", line 223, in request
    elif raise_on_error(response, **processed_kwargs):
  File "/tmp/jira/jira/resilientsession.py", line 69, in raise_on_error
    raise JIRAError(
jira.exceptions.JIRAError: JiraError HTTP 500 url: https://xxx.atlassian.net/rest/api/2/project
        text: Internal server error
        
        response headers = {...}
        response text = {"errorMessages":["Internal server error"],"errors":{}}

@codectl
Copy link
Contributor Author

codectl commented Sep 5, 2022

It fails with 500 for API 3 as well.

The simplest of tests is this:

jira_admin=JIRA(...)
jira_admin.create_project("X", "XYZ")

@adehad
Copy link
Contributor

adehad commented Sep 5, 2022

Very strange, if you are able to get logs from the Jira instance itself that might help us further, but unfortunately I am not sure why we are seeing this behaviour.

@codectl
Copy link
Contributor Author

codectl commented Sep 5, 2022

Very strange, if you are able to get logs from the Jira instance itself that might help us further, but unfortunately I am not sure why we are seeing this behaviour.

Thing is, this is the Cloud . If it was a local server I could check the logs and we could compare server versions . But being a cloud instance, it should all be the same version but possibly isn't . I created my cloud environment less than a month ago. And bcs yours is older it could be linked to a different version. But I'm just guessing here since none of this is documented and I'm assuming your cloud environment does not raise 500.

From here I can create an (extra) Jira ticket to report the situation .

@codectl
Copy link
Contributor Author

codectl commented Sep 6, 2022

Ok as opposed to what I said yesterday, it does seem the cloud has a version linked to it. My cloud instance has the following properties:

{'baseUrl': 'https://xxx.atlassian.net',
 'buildDate': '2022-09-05T12:15:56.000+0000',
 'buildNumber': 100206,
 'defaultLocale': {'locale': 'en_US'},
 'deploymentType': 'Cloud',
 'scmInfo': '40f823cc9831469ea3c6decd06fddaf0ad67f8e2',
 'serverTime': '2022-09-06T08:03:48.153+0000',
 'serverTitle': 'Jira',
 'version': '1001.0.0-SNAPSHOT',
 'versionNumbers': [1001, 0, 0]}

Please confirm that you are using an older version than mine.

@adehad
Copy link
Contributor

adehad commented Sep 30, 2022

Sorry @rena2damas , have been swamped with work, just letting you know I haven't forgotten to look into this further

@codectl
Copy link
Contributor Author

codectl commented Oct 10, 2022

@adehad no problem I myself been also busy but thanks nonetheless

Copy link
Collaborator

@studioj studioj left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution, could you add a test to verify this?

if permissionScheme is None:
if permissionScheme is None and self._is_cloud:
# Let Jira Cloud decide the default field due to issues in handling the
# field. See https://bit.ly/3ALVqgo
Copy link
Collaborator

@studioj studioj Feb 9, 2023

Choose a reason for hiding this comment

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

I don't think many people will open a random bit.ly address in some comments. could you paste the full URL here? It might look slightly uglier but at least people won't open this in a burner VM like I did :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create project with 'permissionScheme' field is causing 500
3 participants