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

Getting a response of 500 when attempting to create asset with asset_class specified. #792

Closed
rithviknishad opened this issue May 27, 2022 · 12 comments · Fixed by #793
Closed
Assignees

Comments

@rithviknishad
Copy link
Member

Steps to reproduce the behavior:

  1. Create new asset with asset_class attribute included with a valid value (eg: "ONVIF" / "HL7MONITOR")

Expected behavior
201 Response

Screenshots

image

However, endpoint works fine when asset_class is not included.

image

@rithviknishad
Copy link
Member Author

@vigneshhari @iamsdas still getting 500 as response :/
Am I doing something wrong or...?

image

@rithviknishad rithviknishad reopened this Jun 3, 2022
@rithviknishad rithviknishad added the bug Something isn't working label Jun 3, 2022
@iamsdas
Copy link
Contributor

iamsdas commented Jun 3, 2022

@rithviknishad have you pulled the latest changes from the master branch? It seems to be working fine for me locally (using the Swagger UI). Also, check if you are providing the necessary input fields.

Here's the request body I used for testing:

{
  "asset_type": "INTERNAL",
  "location_object": {
    "facility": {
      "name": "facility #1"
    },
    "name": "al 1",
    "description": "string",
    "location_type": 10
  },
  "location": "18b21291-1c87-4bfc-8c02-f60c5ccc285f",
  "name": "asset name",
  "description": "string",
  "asset_class": "ONVIF",
  "is_working": true,
  "not_working_reason": "string",
  "serial_number": "string",
  "warranty_details": "string",
  "meta": {},
  "vendor_name": "string",
  "support_name": "string",
  "support_phone": "+919999999999",
  "support_email": "user@example.com",
  "qr_code_id": null
}

Screenshot_20220603_155057

@rithviknishad
Copy link
Member Author

@iamsdas I'm using the staging API via proxy mentioned in care_fe/package.json

I'm yet to setup a local care BE on my machine.

image

  • What I'm performing is:
curl 'https://careapi.coronasafe.in/api/v1/asset/' \
        -X POST \
        -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:100.0) Gecko/20100101 Firefox/100.0' \
        -H 'Accept: application/json, text/plain, */*' \
        -H 'Accept-Language: en-US,en;q=0.5' \
        -H 'Accept-Encoding: gzip, deflate, br' \
        -H 'Content-Type: application/json' \
        -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjU0MjU4MjY5LCJqdGkiOiIwZjgyMTQ5Mzc4MjY0ZWUyYTJmNzVlNDFmYzllMmRjMSIsInVzZXJfaWQiOjIwMn0.gp1grpzzKDH3ZCPoRSI_XTLX-IoZnWDATUcZQpolwuU' \
        -H 'Origin: http://localhost:4000' \
        -H 'Connection: keep-alive' \
        -H 'Referer: http://localhost:4000/facility/4fa7d5bf-1862-4ebb-b2d1-8284d12185ac/assets/new' \
        -H 'Sec-Fetch-Dest: empty' \
        -H 'Sec-Fetch-Mode: cors' \
        -H 'Sec-Fetch-Site: same-origin' \
        --data-raw ' 
{                              
  "name": "Hello Asset :wave:",
  "asset_type": "INTERNAL",
  "asset_class": "ONVIF",
  "description": "",   
  "is_working": "true",    
  "not_working_reason": "",
  "serial_number": "",   
  "warranty_details": "",                            
  "location": "afa28ab1-53f5-4554-8cb0-77c1e5d58c37",
  "vendor_name": "", 
  "support_name": "", 
  "support_email": "",             
  "support_phone": "+917777777777",
  "qr_code_id": "",
  "cancelToken": {
    "promise": {}
  }
}'
  • And I'm getting the following for the above.
    image

  • However, if I just remove asset_class attribute in the same above cURL command:

curl 'https://careapi.coronasafe.in/api/v1/asset/' \
        -X POST \
        -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:100.0) Gecko/20100101 Firefox/100.0' \
        -H 'Accept: application/json, text/plain, */*' \
        -H 'Accept-Language: en-US,en;q=0.5' \
        -H 'Accept-Encoding: gzip, deflate, br' \
        -H 'Content-Type: application/json' \
        -H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjU0MjU4MjY5LCJqdGkiOiIwZjgyMTQ5Mzc4MjY0ZWUyYTJmNzVlNDFmYzllMmRjMSIsInVzZXJfaWQiOjIwMn0.gp1grpzzKDH3ZCPoRSI_XTLX-IoZnWDATUcZQpolwuU' \
        -H 'Origin: http://localhost:4000' \
        -H 'Connection: keep-alive' \
        -H 'Referer: http://localhost:4000/facility/4fa7d5bf-1862-4ebb-b2d1-8284d12185ac/assets/new' \
        -H 'Sec-Fetch-Dest: empty' \
        -H 'Sec-Fetch-Mode: cors' \
        -H 'Sec-Fetch-Site: same-origin' \
        --data-raw '
{
  "name": "Hello Asset :wave:",
  "asset_type": "INTERNAL",
  "description": "",
  "is_working": "true",
  "not_working_reason": "",
  "serial_number": "",
  "warranty_details": "",
  "location": "afa28ab1-53f5-4554-8cb0-77c1e5d58c37",
  "vendor_name": "",
  "support_name": "",
  "support_email": "",
  "support_phone": "+917777777777",
  "qr_code_id": "",
  "cancelToken": {
    "promise": {}
  }
}'
  • I'm getting a good response for that:
    image

@sainak
Copy link
Member

sainak commented Jun 3, 2022

The asset_class expects an integer
Exception: https://sentry.io/organizations/coronasafe-network/issues/3306110898/

@rithviknishad
Copy link
Member Author

Weren't the migrations run automatically? It's a char field in the last change.

@sainak
Copy link
Member

sainak commented Jun 3, 2022

It's waiting for deployment https://github.com/coronasafe/care/deployments/activity_log?environment=Staging-egov

@mathew-alex @tomahawk-pilot can you update the staging to deploy automatically?

@tomahawk-pilot
Copy link
Member

We can but let it be there. Since we have multiple instances being deployed to

@sainak
Copy link
Member

sainak commented Jun 4, 2022

We can but let it be there. Since we have multiple instances being deployed to

@tomahawk-pilot I'm asking auto deployments only for Staging-egov, If the review requirement could be removed for Staging-egov environment the FE development and testing won't be blocked by pending deployments.

@tomahawk-pilot
Copy link
Member

We can but let it be there. Since we have multiple instances being deployed to

@tomahawk-pilot I'm asking auto deployments only for Staging-egov, If the review requirement could be removed for Staging-egov environment the FE development and testing won't be blocked by pending deployments.

Feel free to remove the review requirements for staging egov environment

@rithviknishad rithviknishad removed the bug Something isn't working label Jun 4, 2022
@rithviknishad
Copy link
Member Author

@iamsdas working now! Great :)
@sainak will you be moving this to a new issue as the original issue is now solved.

@sainak
Copy link
Member

sainak commented Jun 4, 2022

We can but let it be there. Since we have multiple instances being deployed to

@tomahawk-pilot I'm asking auto deployments only for Staging-egov, If the review requirement could be removed for Staging-egov environment the FE development and testing won't be blocked by pending deployments.

Feel free to remove the review requirements for staging egov environment

I don't have the privileges for it.

@mathew-alex
Copy link
Contributor

@sainak - I have removed the review requirements for staging egov environment. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants