canonical / canonical/postgresql-operator

Running list-backups actions shortly after relation with s3-integrator results in IndexError

Open
#699 2 comments 1 reaction 0 assignees View on GitHub
bug good first issue
Dominant language
Python
Stars
20
Forks
36
Avg merge
4d 15h
Merged PRs (30d)
30

Description

## Steps to reproduce

1. juju deploy postgresql --revision 526
2. juju deploy s3-integrator
3. juju run s3-integrator/0 sync-s3-credentials access-key= secret-key=
4. juju config s3-integrator endpoint= bucket= path= region=
5. as soon as relation formed, juju run postgresql/leader list-backups

## Expected behavior
No exceptions throws, action completes successfully

## Actual behavior

Error thrown

## Versions

Operating system: Ubuntu 24.04

Juju CLI: 3.6.1-genericlinux-amd64

Juju agent: 3.6.0

Charm revision: 526

LXD: 5.21.2 LTS

## Log output

Juju debug log:
```
unit-postgresql-0: 14:40:27 ERROR unit.postgresql/0.juju-log Uncaught exception while in charm code:
Traceback (most recent call last):
File "/var/lib/juju/agents/unit-postgresql-0/charm/./src/charm.py", line 1972, in
main(PostgresqlOperatorCharm)
File "/var/lib/juju/agents/unit-postgresql-0/charm/venv/ops/__init__.py", line 343, in __call__
return _main.main(charm_class=charm_class, use_juju_for_storage=use_juju_for_storage)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/juju/agents/unit-postgresql-0/charm/venv/ops/_main.py", line 543, in main
manager.run()
File "/var/lib/juju/agents/unit-postgresql-0/charm/venv/ops/_main.py", line 529, in run
self._emit()
File "/var/lib/juju/agents/unit-postgresql-0/charm/venv/ops/_main.py", line 518, in _emit
_emit_charm_event(self.charm, self.dispatcher.event_name, self._juju_context)
File "/var/lib/juju/agents/unit-postgresql-0/charm/venv/ops/_main.py", line 134, in _emit_charm_event
event_to_emit.emit(*args, **kwargs)
File "/var/lib/juju/agents/unit-postgresql-0/charm/venv/ops/framework.py", line 347, in emit
framework._emit(event)
File "/var/lib/juju/agents/unit-postgresql-0/charm/venv/ops/framework.py", line 857, in _emit
self._reemit(event_path)
File "/var/lib/juju/agents/unit-postgresql-0/charm/venv/ops/framework.py", line 947, in _reemit
custom_handler(event)
File "/var/lib/juju/agents/unit-postgresql-0/charm/lib/charms/tempo_coordinator_k8s/v0/charm_tracing.py", line 1064, in wrapped_function
return callable(*args, **kwargs) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/juju/agents/unit-postgresql-0/charm/src/backups.py", line 988, in _on_list_backups_action
formatted_list = self._generate_backup_list_output()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/juju/agents/unit-postgresql-0/charm/lib/charms/tempo_coordinator_k8s/v0/charm_tracing.py", line 1064, in wrapped_function
return callable(*args, **kwargs) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lib/juju/agents/unit-postgresql-0/charm/src/backups.py", line 388, in _generate_backup_list_output
backups = json.loads(output)[0]["backup"]
~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
unit-postgresql-0: 14:40:27 WARNING unit.postgresql/0.list-backups Uncaught IndexError in charm code: list index out of range
unit-postgresql-0: 14:40:27 WARNING unit.postgresql/0.list-backups Use `juju debug-log` to see the full traceback.
```

```
$ juju run postgresql/0 list-backups
Running operation 5 with 1 task
- task 6 on unit-postgresql-0

Waiting for task 6...
Action id 6 failed: exit status 1

Uncaught IndexError in charm code: list index out of range
Use `juju debug-log` to see the full traceback.
```

## Additional context

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.