Skip to content

script should not crash when zero features are present #226

@smnorris

Description

@smnorris

Not sure if the count is correct, but regardless - script should fail more gracefully than this:

bcdata bc2pg -r whse_land_and_natural_resource.prot_current_fire_polys_sp
2025-09-30 02:25:43,020:INFO:bcdata.wfs: Total features requested: 0
Traceback (most recent call last):
  File "/opt/venv/bin/bcdata", line 7, in <module>
    sys.exit(cli())
             ^^^^^
  File "/opt/venv/lib/python3.12/site-packages/click/core.py", line 1462, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/click/core.py", line 1383, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/click/core.py", line 1850, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/click/core.py", line 1246, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/bcdata/cli.py", line 378, in bc2pg
    out_table = bcdata.bc2pg(
                ^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.12/site-packages/bcdata/bc2pg.py", line 98, in bc2pg
    df = WFS.request_features(url=urls[0], as_gdf=True, lowercase=True)
                                  ~~~~^^^
IndexError: list index out of range

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions