Skip to content

Fix AttributeError when importing eyepieces from DeepskyLog#529

Open
brickbots wants to merge 1 commit into
mainfrom
fix/dsl-eyepiece-import-crash
Open

Fix AttributeError when importing eyepieces from DeepskyLog#529
brickbots wants to merge 1 commit into
mainfrom
fix/dsl-eyepiece-import-crash

Conversation

@brickbots

Copy link
Copy Markdown
Owner

Summary

Importing equipment from DeepskyLog on the web interface crashes with an "Internal Server Error" as soon as the import contains a new eyepiece. This is a v2.5.1 → v2.6.0 regression introduced by the Flask migration (#331), which changed the eyepiece-add call from

cfg.equipment.add_eyepiece(new_eyepiece)

to

cfg.equipment.eyepieces.add_eyepiece(new_eyepiece)

Equipment.eyepieces is a plain List[Eyepiece] with no add_eyepiece method, so the first new eyepiece raises AttributeError. Since cfg.save_equipment() comes after the import loop, nothing gets saved — telescopes already collected in the same request are lost too.

This PR restores the pre-migration call on Equipment itself (equipment.py:87), which appends the eyepiece and keeps the list sorted by focal length. The manual add-eyepiece route was unaffected (it already calls the correct method at server.py:736).

Test plan

  • ruff check / ruff format --check pass on server.py
  • pytest -m smoke passes (5 passed)
  • Verified Equipment.add_eyepiece appends + sorts, and that a plain list has no add_eyepiece attribute (the crash path)

🤖 Generated with Claude Code

The Flask migration (#331) changed the DeepskyLog eyepiece import to
call add_eyepiece() on Equipment.eyepieces, which is a plain list with
no such method. The first new eyepiece raised AttributeError, surfacing
as "Internal Server Error", and nothing was saved since save_equipment()
comes after the loop. Restore the pre-migration call on Equipment
itself, which also keeps the eyepiece list sorted by focal length.

Regression: v2.5.1 -> v2.6.0 (9e96d22)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mrosseel

Copy link
Copy Markdown
Collaborator

Seems like this cold use a unit test/integration test. Are these run regularly btw?

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