Project

Profile

Help

Issue #3393

closed

API break: unit_key became mandatory during RPM upload

Added by rmcgover almost 7 years ago. Updated over 5 years ago.

Status:
CLOSED - DUPLICATE
Priority:
Normal
Assignee:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Sprint:
Quarter:

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

Is duplicate of RPM Support - Issue #3307: import_upload: improve data validationCLOSED - CURRENTRELEASEdaviddavisActions
Actions #1

Updated by dalley almost 7 years ago

  • Related to Issue #3307: import_upload: improve data validation added
Actions #2

Updated by dalley almost 7 years ago

  • Status changed from NEW to CLOSED - DUPLICATE
  • Triaged changed from No to Yes
Actions #3

Updated by amacdona@redhat.com almost 7 years ago

  • Related to deleted (Issue #3307: import_upload: improve data validation)
Actions #4

Updated by amacdona@redhat.com almost 7 years ago

  • Is duplicate of Issue #3307: import_upload: improve data validation added
Actions #5

Updated by bmbouter over 5 years ago

  • Tags Pulp 2 added

Also available in: Atom PDF