Skip to content
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

Fix index out of range for drift detection returning no results #1220

Merged
merged 2 commits into from
Jul 17, 2023

Conversation

skiptomyliu
Copy link
Member

@skiptomyliu skiptomyliu commented Jul 17, 2023

It's possible for neo4j sessions read_transaction in get_state to return an empty list in the drift detection module.

This PR ensures that there are entries before referencing index 0.

File "/code/venvs/venv/lib/python3.8/site-packages/cartography/driftdetect/get_states.py", line 123, in get_query_state
    get_state(session, state)
  File "/code/venvs/venv/lib/python3.8/site-packages/cartography/driftdetect/get_states.py", line 148, in get_state
    state.properties = list(new_results[0].keys())
IndexError: list index out of range

@skiptomyliu skiptomyliu changed the title Fix indexError for drift detection returning no results Fix index out of range for drift detection returning no results Jul 17, 2023
@skiptomyliu skiptomyliu enabled auto-merge (squash) July 17, 2023 17:59
@skiptomyliu skiptomyliu merged commit ff94338 into master Jul 17, 2023
4 checks passed
@skiptomyliu skiptomyliu deleted the hotfix-driftdetect-index branch July 17, 2023 18:08
ramonpetgrave64 pushed a commit that referenced this pull request Aug 3, 2023
It's possible for neo4j sessions `read_transaction` in `get_state` to
return an empty list in the drift detection module.

This PR ensures that there are entries before referencing index 0.
```
File "/code/venvs/venv/lib/python3.8/site-packages/cartography/driftdetect/get_states.py", line 123, in get_query_state
    get_state(session, state)
  File "/code/venvs/venv/lib/python3.8/site-packages/cartography/driftdetect/get_states.py", line 148, in get_state
    state.properties = list(new_results[0].keys())
IndexError: list index out of range
```
chandanchowdhury pushed a commit to juju4/cartography that referenced this pull request Jun 26, 2024
…#1220)

It's possible for neo4j sessions `read_transaction` in `get_state` to
return an empty list in the drift detection module.

This PR ensures that there are entries before referencing index 0.
```
File "/code/venvs/venv/lib/python3.8/site-packages/cartography/driftdetect/get_states.py", line 123, in get_query_state
    get_state(session, state)
  File "/code/venvs/venv/lib/python3.8/site-packages/cartography/driftdetect/get_states.py", line 148, in get_state
    state.properties = list(new_results[0].keys())
IndexError: list index out of range
```
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