find_source_in_db's spatial fallback search crashes on a completely empty Sources table

Open Beginner friendly
#101 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
database

Research direction

Start at astrodb_utils.sources.find_source_in_db, reached through ingest_source and the astrodb-ingest-sources generated script, and reproduce the first ingest against an empty Sources table with search_db=True. Confirm that the spatial fallback handles zero rows without a column-indexing crash, then check the skill instructions for the documented first-ingest workaround. Done means the empty-table case is handled or clearly documented without disrupting incremental searches.

Written by the indexing model from the issue text.

Description

Where: astrodb_utils.sources.find_source_in_db (via ingest_source with search_db=True), called from the astrodb-ingest-sources skill's generated script.

What happened: Ingesting the very first source into a brand-new, completely empty Sources table with search_db=True failed on every single row with "None of [Index(['ra_deg', 'dec_deg'], dtype='str')] are in the [columns]". This comes from find_source_in_db's coordinate-based db.query_region(...) fallback (reached because there's no name match yet), which appears to return a DataFrame with no columns at all when queried against a table with zero rows, so the subsequent db_name_matches[ra_col_name] access fails.

Workaround: Set search_db=False for this first bulk ingest into a fresh table — there is nothing to dedupe against yet, so skipping the search entirely is correct and cheap. This would need to be revisited (search_db=True) for any future incremental ingest into an already-populated Sources table.

Suggested change: astrodb-ingest-sources's skill instructions could note this edge case explicitly: "if this is the first ingest into an empty database, prefer search_db=False, since find_source_in_db's spatial-search fallback errors on a zero-row table rather than returning zero matches." Longer-term, the fix belongs in astrodb_utils.sources.find_source_in_db (guard the empty-table case before indexing into db_name_matches).


Reported from a gotchas.md log filed by a skill user (2026-08-28).

Dominant language
Python
Stars
1
Forks
4
Avg merge
2d 10h
Merged PRs (30d)
5

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from astrodbtoolkit/astrodb-bot

All issues in astrodbtoolkit/astrodb-bot

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.