Skip to content

fix(folders): don't send "None" as the folder description - #212

Merged
deveaud-m merged 3 commits into
fossology:mainfrom
syahra712:fix-folder-description-none
Oct 30, 2026
Merged

deveaud-m merged 3 commits into
fossology:mainfrom
syahra712:fix-folder-description-none

Conversation

@syahra712

@syahra712 syahra712 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

When create_folder() is called without a description, it sends folderDescription: None as a string, so the new folder gets the description "None". With this fix the header is only sent when a description is given. I added a test that runs against a real Fossology instance through the foss fixture. It fails on main (the description is stored as "None").

AI-assisted (Claude). I reviewed the code and ran the tests.

create_folder() put f"{description}" into the folderDescription
header, so a folder created without a description was stored with
the literal description "None". Only send the header when a
description is given, and add a mocked test for it.

Signed-off-by: 72004 <syahra2014@gmail.com>
Assisted-by: Claude
Comment thread tests/test_folders.py Outdated
assert f"Unable to get a list of folders for {foss.user.name}" in str(excinfo.value)


def _offline_foss(url: str) -> Fossology:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For change in the API logic - not just the expected responses - we need a real test against a locally running Fossology instance.

The testsuite covers this when using the fixture foss like in other tests.

The test should be successful against a "real" Fossology instance, not an offline one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that makes sense. In 976d2b5 I replaced the mocked test with test_create_folder_without_description(foss), which uses the foss fixture. It creates a folder without a description on a running server, checks that the stored description is "", and deletes the folder.

I ran tests/test_folders.py against fossology/fossology:4.7.1 (the CI image) in Docker. All 15 tests pass with the fix. Without it, the new test fails with assert 'None' == ''.

Replace the mocked test with one that uses the foss fixture, so the
description stored by a running Fossology server is checked. It fails
without the fix (the description is stored as 'None').

Assisted-by: Claude
Signed-off-by: 72004 <syahra2014@gmail.com>
@deveaud-m

Copy link
Copy Markdown
Collaborator

@syahra712 the testsuite throws an error, can you please have a look at it and provide a fix? Thanks!

secrets.randbelow(192) can pick the id of an upload created earlier in
the run, so the 'does not exist' test sometimes got a real upload back.

Signed-off-by: 72004 <syahra2014@gmail.com>
Assisted-by: Claude
@syahra712

Copy link
Copy Markdown
Contributor Author

@deveaud-m The failure is test_change_upload_permissions_if_upload_does_not_exists_raise_api_error, not a folder test. It builds its "missing" upload with secrets.randbelow(192) as the id, and uploads created earlier in the run have ids in that range. So it sometimes hits a real upload and no error is raised. That's why it can fail on any PR.

I pushed a small fix in this PR: both "does not exist" permission tests now use ids from 1,000,000 up. Happy to split it into its own PR if you prefer.

@deveaud-m
deveaud-m merged commit 3c38e3d into fossology:main Oct 30, 2026
2 checks passed
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.

2 participants