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
v5.2.0 breaking change? AttributeError: type object 'Meta' has no attribute 'read_capacity_units' #1017
Comments
Must've been unintentional. Gotta look into this. |
@lehmat What is the stack trace where this error happens for you? |
|
The problem reproduces for me with both 5.1.0 and 5.2.0, although it crashes in a slightly different place, but with the same error. The full code: from pynamodb.attributes import UnicodeAttribute
from pynamodb.indexes import GlobalSecondaryIndex, AllProjection
from pynamodb.models import Model
class UserRangeKey(GlobalSecondaryIndex):
class Meta:
index_name = "user-range-key-index"
projection = AllProjection()
user_range_key = UnicodeAttribute(hash_key=True)
class MyModel(Model):
class Meta:
host = 'http://localhost:8000'
table_name = 'foo'
aws_access_key_id = ' foo'
aws_session_token = 'foo'
aws_secret_access_key = 'foo'
user_range_key = UserRangeKey()
MyModel.create_table() |
Facing same issue |
@nirajvbhatt Do you have simple code which reproduces the problem on 5.2 but not 5.1? |
Hey @ikonst , sorry for late reply. I couldn't reproduce the issue on 5.2. |
I have the same issue. Below is simple code:
Stack trace:
|
Output from
|
Ahh, you guys are right. I think the culprit is this: We used to check for the model's billing mode: Line 908 in 4bbfad6
but now we're expecting the index to have a billing mode: Line 175 in 1111328
|
You are correct @ikonst. The ticket was about adding a notice in the releases to avoid people looking at the releases and come to a conclusion that no change is required. Overall I think it is good to be able to being able to define billing mode for the global secondary index |
Cool, thx for the solution!! |
@lehmat per UpdateTable docs, you cannot define a billing mode just for an index - it's always per the entire table and all its indices. So this 5.2.0 change looks like a bug that we need to fix. |
@ikonst Agree this is a bug to be fixed -- really we want to check the billing mode of the table to see if we should add provisioned throughput to the index settings. We also might want to change the checks to explicitly check for the "PROVISIONED" billing mode. |
For reference the original logic correctly looked at the model Meta:
|
Am I missing something? https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-gsi.html#cfn-dynamodb-gsi-provisionedthroughput, you can specify provisioned throughput for global secondary indexes |
@lehmat You can specify a separate throughput for each GSI, but not separate billing mode. Billing mode is a table-level setting. |
Note that I've backported the fix from #1018 in a 5.2.1 release: https://pypi.org/project/pynamodb/5.2.1/ |
The release of 5.2.0 broke GlobalSecondaryIndex syntax that worked on 5.1.0. Requesting to add a note about it in release notes for 5.2.0
Broken syntax in 5.2.0, but working in 5.1.0
Valid syntax in 5.2.0
Lines it breaks in is in PR #996
The text was updated successfully, but these errors were encountered: