Skip to content

fix: enforce minimum one obligation requirement for licenses (Issue #136)#194

Open
abhayrajjais01 wants to merge 5 commits intofossology:mainfrom
abhayrajjais01:fix/issue-136-obligation-validation
Open

fix: enforce minimum one obligation requirement for licenses (Issue #136)#194
abhayrajjais01 wants to merge 5 commits intofossology:mainfrom
abhayrajjais01:fix/issue-136-obligation-validation

Conversation

@abhayrajjais01
Copy link
Copy Markdown

Description

Fixes #136 - Enforces that licenses cannot exist without at least one obligation attached.

Changes

  • ✅ Added validation to CreateLicense endpoint (before DB transaction)
  • ✅ Added validation to UpdateLicense endpoint
  • ✅ Added validation to InsertOrUpdateLicenseOnImport function
  • ✅ Updated existing tests to include obligations
  • ✅ Added new test case for license creation without obligations
  • ✅ Created getTestObligation() helper function for tests

Addresses PR #191 Review Feedback

  • ✅ Validation occurs before database transactions (not after)
  • ✅ Added obligation validation to UpdateLicense endpoint
  • ✅ Updated all failing test cases
  • ✅ Clear, user-friendly error messages

Testing

  • All existing tests updated to include obligations
  • New test case added: TestCreateLicense/withoutObligations
  • Tests require PostgreSQL database to run

Breaking Changes

Warning

This is a breaking change. Existing code that creates/updates licenses without obligations will now fail with 400 Bad Request.

Error Messages

CreateLicense: "cannot create license without obligations"
UpdateLicense: "cannot update license to have zero obligations"
ImportLicenses: "cannot import license without obligations: at least one obligation is required"

…ossology#136)

- Add validation to CreateLicense endpoint to reject licenses without obligations
- Add validation to UpdateLicense endpoint to prevent removing all obligations
- Add validation to ImportLicenses flow for imported licenses
- Update existing tests to include obligations
- Add new test case for license creation without obligations
- Create getTestObligation() helper function for tests

Addresses all feedback from PR fossology#191:
- Validation occurs before database transactions (not after)
- UpdateLicense endpoint now validates obligations
- All test cases updated and passing
- Clear, user-friendly error messages

Fixes fossology#136

Signed-off-by: abhayrajjais01 <abhayraj916146@gmail.com>
@abhayrajjais01 abhayrajjais01 force-pushed the fix/issue-136-obligation-validation branch from 8161b24 to 416e7ee Compare January 25, 2026 18:19
Signed-off-by: Abhayraj Jaiswal <205578164+abhayrajjais01@users.noreply.github.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.

License Creation

1 participant