Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axis 360 loan exception (PP-1910) #2165

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

jonathangreen
Copy link
Member

@jonathangreen jonathangreen commented Nov 14, 2024

Description

  • Update LoanInfo to remove the fulfillment attribute since it is confusing, and only used in the Axis360 API code.
  • Add AxisLoanInfo which extends LoanInfo with the extra fulfillment attribute, and update the Axis360 API code to use this new class.
  • Add some type hints to licensing.py that would have caught this issue if they had existed before.

JIRA: PP-1910

Motivation and Context

In #2113 it looks like I confused the LoanInfo.fulfillment parameter with Loan.fulfillment. These are actually different types and represent different things.

This was resulting in the following traces in our logs:

Traceback (most recent call last):
  File "/var/www/circulation/src/palace/manager/celery/tasks/patron_activity.py", line 75, in sync_patron_activity
    api.sync_patron_activity(patron, pin)
  File "/var/www/circulation/src/palace/manager/api/circulation.py", line 852, in sync_patron_activity
    self.sync_loans(patron, remote_loans, local_loans)
  File "/var/www/circulation/src/palace/manager/api/circulation.py", line 826, in sync_loans
    loan.create_or_update(patron)
  File "/var/www/circulation/src/palace/manager/api/circulation.py", line 415, in create_or_update
    loan, is_new = loanable.loan_to(
  File "/var/www/circulation/src/palace/manager/sqlalchemy/model/licensing.py", line 1069, in loan_to
    loan.fulfillment = fulfillment
  File "/var/www/circulation/env/lib/python3.10/site-packages/sqlalchemy/orm/attributes.py", line 465, in __set__
    self.impl.set(
  File "/var/www/circulation/env/lib/python3.10/site-packages/sqlalchemy/orm/attributes.py", line 1286, in set
    value = self.fire_replace_event(state, dict_, value, old, initiator)
  File "/var/www/circulation/env/lib/python3.10/site-packages/sqlalchemy/orm/attributes.py", line 1312, in fire_replace_event
    value = fn(
  File "/var/www/circulation/env/lib/python3.10/site-packages/sqlalchemy/orm/unitofwork.py", line 119, in set_
    newvalue_state = attributes.instance_state(newvalue)
AttributeError: 'Axis360AcsFulfillment' object has no attribute '_sa_instance_state'

I believe this is occurring both during loan, and during the sync process.

How Has This Been Tested?

  • Running tests in CI

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@jonathangreen jonathangreen added the bug Something isn't working label Nov 14, 2024
@jonathangreen jonathangreen requested a review from a team November 14, 2024 14:18
@jonathangreen jonathangreen changed the title Axis 360 loan exception Axis 360 loan exception (PP-1910) Nov 14, 2024
Copy link

codecov bot commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 90.79%. Comparing base (01d0861) to head (0aa63f8).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/palace/manager/api/circulation.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2165   +/-   ##
=======================================
  Coverage   90.78%   90.79%           
=======================================
  Files         351      351           
  Lines       40716    40716           
  Branches     8822     8822           
=======================================
+ Hits        36966    36969    +3     
+ Misses       2441     2438    -3     
  Partials     1309     1309           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant