Skip to content

Conversation

CraigBryan
Copy link

Fixed unsafe lookup of externalId, pollingIntervalCronExpression, and ingestionSourcesOverrides

@CraigBryan CraigBryan requested review from a team as code owners February 28, 2025 21:06
@CraigBryan
Copy link
Author

I was trying to use this function to update the custom tags for a google_cloud integration and got a series of errors due to some unsafe lookups in the dictionary.

Examples:

> j1.update_integration_instance_config_value(instance_id="<integration id>", config_key="@tag", config_value={'AccountName': 'Value', "JiraProject": "Value"})

File ~/.pyenv/versions/3.12.4/envs/gcp_sa_project_mapping/lib/python3.12/site-packages/jupiterone/client.py:717, in JupiterOneClient.update_integration_instance_config_value(self, instance_id, config_key, config_value)
    714 instance_config['data']['integrationInstance']['config'] = config_dict
    716 # remove externalId to not include in update payload
--> 717 del instance_config['data']['integrationInstance']['config']['externalId']
    719 # prepare variables GraphQL payload for updating config
    720 instance_details = instance_config['data']['integrationInstance']

KeyError: 'externalId'
> j1.update_integration_instance_config_value(instance_id="<integration id>", config_key="@tag", config_value={'AccountName': 'Value', "JiraProject": "Value"})
     30 variables = {
     31     "id": instance_details["id"],
     32     "update": {
   (...)
     44     },
     45 }
     47 # remove problem fields from previous response
---> 48 del variables["update"]["pollingIntervalCronExpression"]["__typename"]
     50 for ingestion_source in instance_details["ingestionSourcesOverrides"]:
     51     ingestion_source.pop(
     52         "__typename", None
     53     )  # Removes key if it exists, ignores if not

TypeError: 'NoneType' object does not support item deletion

@SeaBlooms
Copy link

Thanks @CraigBryan we will review and fix

SeaBlooms
SeaBlooms previously approved these changes Mar 21, 2025
@SeaBlooms SeaBlooms merged commit 9342186 into JupiterOne:main Mar 25, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants