Skip to content

fix delete_relationship() method#66

Merged
SeaBlooms merged 3 commits intomainfrom
TD-8043-2.2.0-release
Mar 26, 2026
Merged

fix delete_relationship() method#66
SeaBlooms merged 3 commits intomainfrom
TD-8043-2.2.0-release

Conversation

@SeaBlooms
Copy link

@SeaBlooms SeaBlooms commented Mar 24, 2026

Update delete_relationship() to match current GraphQL API

Summary

  • The deleteRelationship GraphQL mutation now requires fromEntityId and toEntityId in addition to relationshipId. Updated the mutation in constants.py and the delete_relationship() method in client.py to pass all three required fields.
  • Added input validation for the new required parameters.
  • Updated README, examples, and tests to reflect the new method signature.
  • Improved test coverage: tests now assert the outgoing GraphQL request contains the correct variables, and validate that missing required params raise errors.

Files changed

File Change
jupiterone/constants.py Added $fromEntityId and $toEntityId to the DeleteRelationship mutation
jupiterone/client.py Updated delete_relationship() signature and validation
tests/test_delete_relationship.py Rewrote tests to assert outgoing request variables; added validation error tests
README.md Updated delete relationship documentation
examples/03_relationship_management.py Updated all delete_relationship() call sites with new required params
examples/06_advanced_operations.py Updated bulk delete/update to track and pass from/to entity IDs
examples/examples.py Updated delete_relationship() usage
setup.py Version bump to 2.2.0

Note on backwards compatibility

This is technically a breaking change to the delete_relationship() signature, but the previous implementation was already non-functional — the GraphQL API had been updated to require fromEntityId and toEntityId, so any existing call with only relationshipId was returning a server-side error. This release fixes the method to work against the current API.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Python client’s delete_relationship() implementation to align with the current JupiterOne GraphQL API requirements by supplying fromEntityId and toEntityId in addition to relationshipId, and propagates the new call signature through docs, examples, and tests.

Changes:

  • Update the DeleteRelationship GraphQL mutation and delete_relationship() client method to require from_entity_id and to_entity_id, with optional timestamp.
  • Refresh README + example call sites to use the new delete_relationship() signature.
  • Bump package version and adjust the existing delete-relationship test invocation.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
jupiterone/constants.py Updates the DELETE_RELATIONSHIP mutation to include fromEntityId and toEntityId.
jupiterone/client.py Updates delete_relationship() signature, adds validation, and passes new variables.
tests/test_delete_relationship.py Updates the test call to include new required parameters.
README.md Updates documentation examples for deleting relationships with new required args.
examples/examples.py Updates delete_relationship() usage to provide entity IDs.
examples/03_relationship_management.py Updates relationship deletion examples to pass required entity IDs.
examples/06_advanced_operations.py Tracks relationship endpoints so bulk update/delete can pass required IDs.
examples/test_list_parameter_items.py Adds a new example script for list-type account parameter testing.
examples/snyk_findings_resolved_within_15_days.py Adds a new example script for J1QL + Python-side time filtering/reporting.
setup.py Bumps package version to 2.2.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +3
#!/usr/bin/env python3
"""
Test script: Create an account parameter of the list type with N items.
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

Because this is under examples/ but the filename starts with test_, running pytest from the repo root may try to collect it as a test module (depending on config). Consider renaming the script to avoid the test_ prefix (or adjusting pytest discovery config) so example scripts don’t get unintentionally picked up in CI/dev test runs.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +3
#!/usr/bin/env python3
"""
Find critical Snyk findings linked to resolved issues where the issue
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

PR description lists updates to existing delete-relationship docs/examples/tests, but this PR also adds new example scripts (examples/test_list_parameter_items.py and examples/snyk_findings_resolved_within_15_days.py). Consider updating the PR description’s “Files changed” list (or removing these additions if they’re unintended) to keep the description aligned with the actual change set.

Copilot uses AI. Check for mistakes.
self._validate_entity_id(to_entity_id, "to_entity_id")

if timestamp is not None:
if not isinstance(timestamp, int) or timestamp <= 0:
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

timestamp validation uses isinstance(timestamp, int), which will also accept booleans (True/False) because bool is a subclass of int. Consider explicitly rejecting booleans (e.g., isinstance(timestamp, bool)) so accidental timestamp=True doesn’t get treated as 1 and sent to the API.

Suggested change
if not isinstance(timestamp, int) or timestamp <= 0:
if isinstance(timestamp, bool) or not isinstance(timestamp, int) or timestamp <= 0:

Copilot uses AI. Check for mistakes.
Copy link

Choose a reason for hiding this comment

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

To confirm, this example is a side addition not related to relationship deletion, correct?

README.md Outdated
to_entity_id='<id-of-destination-entity>'
)

# Delete with timestamp
Copy link

Choose a reason for hiding this comment

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

I'm unfamiliar with the purpose of the timestamp argument.
Consider including details on what the timestamp does and why a user would want to include it.

VDubber
VDubber previously approved these changes Mar 25, 2026
Copy link

@VDubber VDubber left a comment

Choose a reason for hiding this comment

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

Left a few comments. Looks good to me!

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@SeaBlooms SeaBlooms requested a review from VDubber March 25, 2026 15:59
@SeaBlooms SeaBlooms merged commit 20d6a53 into main Mar 26, 2026
5 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.

3 participants