CumulusCI icon indicating copy to clipboard operation
CumulusCI copied to clipboard

Running `cci org import org1 org1` on circleci throws `'NoneType' object is not subscriptable`

Open Szandor72 opened this issue 4 years ago • 6 comments

Describe the bug Running cci org import org1 org1 on circleci throws 'NoneType' object is not subscriptable for Scratch Orgs

Edit: The behaviour does also occur on 3.30.

Reproduction steps I have a windows machine, so I cannot reproduce behaviour.

Context circleci image: circleci/python:3.7.4-browsers

CumulusCI version: 3.31.0 (/usr/local/bin/cci)
Python version: 3.7.4 (/usr/local/bin/python)

You have the latest version of CumulusCI.

2021-03-20 09:42:48,463 DEBUG Added a stderr logging handler to logger: urllib3
2021-03-20 09:42:48: Getting org info from Salesforce CLI for browsertest-PropertiesAndCalculation
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/cumulusci/cli/cci.py", line 234, in main
    cli(args[1:], standalone_mode=False)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/cumulusci/cli/cci.py", line 173, in new_func
    func(RUNTIME, *args, **kw)
  File "/usr/local/lib/python3.7/site-packages/cumulusci/cli/cci.py", line 1046, in org_import
    scratch_org_config.config["date_created"] = parse_api_datetime(info["created_date"])
  File "/usr/local/lib/python3.7/site-packages/cumulusci/utils/__init__.py", line 41, in parse_api_datetime
    dt = datetime.strptime(value[0:DATETIME_LEN], API_DATE_FORMAT)
TypeError: 'NoneType' object is not subscriptable
> /usr/local/lib/python3.7/site-packages/cumulusci/utils/__init__.py(41)parse_api_datetime()
-> dt = datetime.strptime(value[0:DATETIME_LEN], API_DATE_FORMAT)

Szandor72 avatar Mar 20 '21 09:03 Szandor72

CCI org import is a confusing command. It is for importing scratch orgs and only scratch orgs. In a CI context I'd suggest you spin up new scratch orgs. Or you can connect an org (probably persistent, no scratch) as described here:

https://cumulusci.readthedocs.io/en/latest/github_actions.html#connect-a-persistent-org

prescod avatar Mar 21 '21 05:03 prescod

Thank you.

My bad, I failed to mention I am trying to import Scratch Orgs.

I just cannot fathom why createddate / the command fails since Friday. This isn't a new setup.

Szandor72 avatar Mar 21 '21 07:03 Szandor72

@Szandor72 If you run sfdx force:org:display --json -u org1, does that output include createdDate?

How did you create the scratch org?

davisagli avatar Mar 21 '21 14:03 davisagli

Thanks for the pointer, David.

The output does not include a createdDate but the org involved is a scratch org.

The scratch org is created in a different circleci step and is re-used in several other steps. We use SFDX auth URLs to authenticate org(s) and prepare some test data. Finally we do a cci org import to run robot tests.

I could confirm this works as expected with DX CLI 7.82 but on 7.92 cci org import fails due to createdDate missing in the json response.

Szandor72 avatar Mar 21 '21 18:03 Szandor72

@Szandor72 I just created a scratch org using sfdx 7.92, and verified that sfdx force:org:display --json includes a createdDate. So I suspect that the problem is related to authenticating the org to the CLI using the auth url and that in that case the CLI is not retrieving the date that the org was created and adding it to the org properties. I don't see an entry in the Salesforce CLI release notes specifically mentioning this as something that changed, but it seems very possible that it could have been affected by the ongoing refactoring that that team is working on.

I don't really understand why you are using auth urls in this scenario. Isn't the org already in the CLI's keychain in ~/.sfdx from when it was created?

In the short term we are going to add a better error message here, indicating that only locally created scratch orgs can be imported. We'll also look into what changes would be needed to support importing a scratch org even if its creation date isn't known, and to import non-scratch orgs, but it may take longer to get to those improvements.

davisagli avatar Mar 22 '21 15:03 davisagli

Thanks again @davisagli,

we are in agreement: the root cause of the issue lies beyond our reach.

There is certainly some legacy aspect involved in our case - yet you surmise correctly, that we are forced to use authUrl because the current keychain in the build step doesn't know the scratch org (yet).

I would appreciate both short and long-term changes concerning importing orgs very much.

Szandor72 avatar Mar 23 '21 12:03 Szandor72

@Szandor72 We have significantly changed the way importing orgs works in the most recent versions of CCI. Do you know if this is still an issue?

davidmreed avatar Oct 07 '22 17:10 davidmreed

Haven't experienced any issues recently. Thanks for the reminder.

Szandor72 avatar Oct 08 '22 14:10 Szandor72