Skip to content

Fix package_content conversion error when adding packages from PurlDB#472

Open
Kaushik-Kumar-CEG wants to merge 1 commit intoaboutcode-org:mainfrom
Kaushik-Kumar-CEG:fix-package-content-conversion-467
Open

Fix package_content conversion error when adding packages from PurlDB#472
Kaushik-Kumar-CEG wants to merge 1 commit intoaboutcode-org:mainfrom
Kaushik-Kumar-CEG:fix-package-content-conversion-467

Conversation

@Kaushik-Kumar-CEG
Copy link

Fixes

Fixes #467

Issue

PurlDB returns package_content as a string (e.g., "binary"), but Django expects an integer. When conversion failed, the old code assigned None to the IntegerField, causing: Field 'package_content' expected a number but got None.

Solution

Added None checks after conversion. If conversion fails, remove the field instead of assigning None, letting Django use the default null value.

Changes Made

  • component_catalog/models.py (line 2663): Added if package_content_value is not None: check
  • component_catalog/views.py (line 1939): Added explicit is not None check
  • Invalid values are now removed instead of being assigned as None

Verification

Tested locally with scripts simulating PurlDB responses.

Before Fix:
image

After Fix:
Screenshot 2026-02-13 155017

Signed-off-by: Kaushik <kaushikrjpm10@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Error: Field 'package_content' expected a number but got 'binary'.

1 participant