Fix AttributeError when importing eyepieces from DeepskyLog#529
Open
brickbots wants to merge 2 commits into
Open
Fix AttributeError when importing eyepieces from DeepskyLog#529brickbots wants to merge 2 commits into
brickbots wants to merge 2 commits into
Conversation
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>
Collaborator
|
Seems like this cold use a unit test/integration test. Are these run regularly btw? |
Drive /equipment/import_from_deepskylog through Flask's test client with pydeepskylog and config mocked, using a real Equipment instance so the plain-list AttributeError from the Flask migration would reproduce. Covers: new eyepieces added (sorted, entities decoded, config saved) and duplicates skipped. Verified the first test fails with AttributeError when the bad call is reintroduced. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Owner
Author
|
Yes indeed! I'll make sure to add a test. Web interface tests don't run as part of the CI/CD, so it's something we'll need to do more of manually as part of a release 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
to
Equipment.eyepiecesis a plainList[Eyepiece]with noadd_eyepiecemethod, so the first new eyepiece raisesAttributeError. Sincecfg.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
Equipmentitself (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 atserver.py:736).Regression tests
tests/test_server_dsl_import.pydrives the real/equipment/import_from_deepskylogroute through Flask's test client, withpydeepskylogandconfig.Configmocked out and a realEquipmentinstance so the plain-list bug reproduces:test_import_adds_new_eyepieces— new eyepieces are added (sorted by focal length, HTML entities decoded) and the config is saved. With the bad call reintroduced, this fails withAttributeError: 'list' object has no attribute 'add_eyepiece'— verified.test_import_skips_existing_eyepiece— an eyepiece already in the config is not duplicated.Test plan
pytest -m "unit or smoke"passes (785 passed)ruff check/ruff format --checkpass🤖 Generated with Claude Code