Issue #3393
closedAPI break: unit_key became mandatory during RPM upload
Description
There appears to have been a backwards-incompatible change to the API of pulp-rpm introduced in commit 62db898a, relea.sed in pulp-rpm-2.13.4-1.
Old behavior: when importing an RPM by POST to import_upload, it's permitted to provide "null" for unit_key.
New behavior: providing "null" for unit_key crashes with:
Feb 23 04:15:05 pulp-03 pulp: pulp_rpm.plugins.importers.yum.upload:ERROR: [4b0d524f] (63534-79328) Traceback (most recent call last):
Feb 23 04:15:05 pulp-03 pulp: pulp_rpm.plugins.importers.yum.upload:ERROR: [4b0d524f] (63534-79328) File "/usr/lib/python2.7/site-packages/pulp_rpm/plugins/importers/yum/upload.py", line 120, in upload
Feb 23 04:15:05 pulp-03 pulp: pulp_rpm.plugins.importers.yum.upload:ERROR: [4b0d524f] (63534-79328) handlers[type_id](repo, type_id, unit_key, metadata, file_path, conduit, config)
Feb 23 04:15:05 pulp-03 pulp: pulp_rpm.plugins.importers.yum.upload:ERROR: [4b0d524f] (63534-79328) File "/usr/lib/python2.7/site-packages/pulp_rpm/plugins/importers/yum/upload.py", line 417, in _handle_package
Feb 23 04:15:05 pulp-03 pulp: pulp_rpm.plugins.importers.yum.upload:ERROR: [4b0d524f] (63534-79328) for key, value in unit_key.items():
Feb 23 04:15:05 pulp-03 pulp: pulp_rpm.plugins.importers.yum.upload:ERROR: [4b0d524f] (63534-79328) AttributeError: 'NoneType' object has no attribute 'items'
The reason for this can be seen clearly in this portion of commit 62db898a:
# Update the RPM-extracted data with anything additional the user specified.
# Allow the user-specified values to override the extracted ones.
- rpm_data.update(metadata or {})
- rpm_data.update(unit_key or {})
-
- # Validate the user specified data by instantiating the model
- try:
- unit = model_class(**rpm_data)
- except TypeError:
- raise ModelInstantiationError()
+ for key, value in metadata.items():
+ setattr(unit, key, value)
+ for key, value in unit_key.items():
+ setattr(unit, key, value)
Where a unit_key of None was previously tolerated, it'll now result in a crash. It would be more friendly to clients if API compatibility were maintained, and clients providing "null" could continue to do so.
Stated as a use-case: as a user of Pulp's APIs, I would like API behavior to be maintained between releases where possible, so that I don't need to update my tools in order to upgrade Pulp.
Related issues
Updated by dalley almost 7 years ago
- Related to Issue #3307: import_upload: improve data validation added
Updated by dalley almost 7 years ago
- Status changed from NEW to CLOSED - DUPLICATE
- Triaged changed from No to Yes
Duplicate of https://pulp.plan.io/issues/3307
Updated by amacdona@redhat.com almost 7 years ago
- Related to deleted (Issue #3307: import_upload: improve data validation)
Updated by amacdona@redhat.com almost 7 years ago
- Is duplicate of Issue #3307: import_upload: improve data validation added