Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(external_ref): Remove unnecessary UpdateExternalRefsJSONPayload type #74

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

deo002
Copy link
Collaborator

@deo002 deo002 commented Jul 4, 2024

Changes

  • Remove unnecessary UpdateExternalRefsJSONPayload type

Submitter Checklist

  • Includes tests (if there is a feature changed/added)
  • Includes docs ( if changes are user facing)
  • I have tested my changes locally.

Copy link
Member

@GMishx GMishx left a comment

Choose a reason for hiding this comment

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

Changes looks good. Needs test.

@GMishx
Copy link
Member

GMishx commented Jul 4, 2024

I am unable to update the external_ref of a license, other fields can be updates. Please check the sample request bellow:

curl -X 'PATCH' \
  'http://localhost:8085/api/v1/licenses/MIT' \
  -H 'accept: application/json' \
  -H 'Authorization: mytoken' \
  -H 'Content-Type: application/json' \
  -d '{
  "external_ref": {
    "license_suffix": "GMishx"
  },
  "rf_risk": 4
}'

image

@deo002
Copy link
Collaborator Author

deo002 commented Jul 5, 2024

I am unable to update the external_ref of a license, other fields can be updates. Please check the sample request bellow:

curl -X 'PATCH' \
  'http://localhost:8085/api/v1/licenses/MIT' \
  -H 'accept: application/json' \
  -H 'Authorization: mytoken' \
  -H 'Content-Type: application/json' \
  -d '{
  "external_ref": {
    "license_suffix": "GMishx"
  },
  "rf_risk": 4
}'

image

image

curl -X 'PATCH'
'http://localhost:5000/api/v1/licenses/MIT'
-H 'accept: application/json'
-H 'Authorization: token
-H 'Content-Type: application/json'
-d '{
"rf_risk": 4,
"external_ref": {
"license_suffix": "GMishX"
}
}'

Wierdly enough, its working for me. I'll look into it.

@deo002 deo002 force-pushed the fix/license_type_issue branch from 32e23c4 to cf243e4 Compare July 5, 2024 09:42
@deo002 deo002 requested a review from GMishx July 8, 2024 05:14
@GMishx
Copy link
Member

GMishx commented Jul 9, 2024

The external_ref still cannot not updated during testing.

@GMishx
Copy link
Member

GMishx commented Jul 15, 2024

From debugging discussion, the default value for external_ref in my Database is null. This causes gorm.Expr("jsonb_strip_nulls(external_ref || ?)", updates.ExternalRef) to return null as null || '{myjson}'::json in PostgreSQL will return null.

I recommend to compare the oldLicense.ExternalRef and updates.ExternalRef in Go to create a final ExternalRef which can be passed to PostgreSQL without using the || operator. Doing so, we can be sure null on either side (existing or new value) should not make the entire JSON object as null.

@deo002 deo002 force-pushed the fix/license_type_issue branch from cf243e4 to a2caaaf Compare July 16, 2024 05:15
Copy link
Member

@GMishx GMishx left a comment

Choose a reason for hiding this comment

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

Tested, working as expected.

@GMishx GMishx removed the needs test label Jul 16, 2024
@GMishx GMishx merged commit 9524e7b into fossology:main Jul 16, 2024
7 checks passed
@GMishx GMishx deleted the fix/license_type_issue branch July 16, 2024 05:43
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