clearlydefined / website

Website for clearlydefined.io
https://clearlydefined.io
MIT License
26 stars 29 forks source link

Contributing through UI appears to be broken #920

Open nellshamrell opened 3 years ago

nellshamrell commented 3 years ago

Example: Making a change here https://clearlydefined.io/definitions/go/golang/github.com%2fdgrijalva/jwt-go/v3.2.0+incompatible to the declared or file licenses does not show up in the UI/UX and the "Contribute" button is still not functional.

qtomlinson commented 2 years ago

This is likely a bug in the service, due to an error in preview call to the service. The same preview call in the local dev environment is successful, and the issue is not reproducible. The failing service call in Dev deployment is: Post call to: https://dev-api.clearlydefined.io/definitions/go/golang/github.com/dgrijalva/jwt-go/v3.2.0+incompatible?matchCasing=false&preview=true body: {described: {releaseDate: "2022-06-04"}}

error response: {"error":{"code":"404","message":"An error has occurred","innererror":{"status":404,"name":"Error","message":"Not Found","stack":"Error: Not Found\n at requestHandler (/opt/service/app.js:212:17)\n at Layer.handle [as handle_request] (/opt/service/node_modules/express/lib/router/layer.js:95:5)\n at trim_prefix (/opt/service/node_modules/express/lib/router/index.js:317:13)\n at /opt/service/node_modules/express/lib/router/index.js:284:7\n at Function.process_params (/opt/service/node_modules/express/lib/router/index.js:335:12)\n at next (/opt/service/node_modules/express/lib/router/index.js:275:10)\n at /opt/service/node_modules/express/lib/router/index.js:635:15\n at next (/opt/service/node_modules/express/lib/router/index.js:260:14)\n at Function.handle (/opt/service/node_modules/express/lib/router/index.js:174:3)\n at router (/opt/service/node_modules/express/lib/router/index.js:47:12)"}}}

qtomlinson commented 2 years ago

@MichaelTsengLZ The issue can be produced on both dev and production servers, but I was not able to reproduce this in the local dev environment. The post preview call to the local service is successful in the dev environment; whereas the post call failed in for the dev deployment. This is where the root cause is suspected to be. Is there a way to find out the version for the production or dev server?

MichaelTsengLZ commented 2 years ago

@qtomlinson Normally, if you could not reproduce locally with local config, try to run the server nodejs app with dev config. The dev environment is already up-to-date. If the dev environment has an issue, then I think you could just run the master branch with dev config. BTW, do you have access to those Dev Azure App Service? https://portal.azure.com/#@clearlydefinedoutlook.onmicrosoft.com/resource/subscriptions/e05584a1-ed97-4676-aec9-d82ba4c36c93/resourceGroups/clearlydefined-dev/providers/Microsoft.Web/sites/clearlydefined-api-dev/appServices

qtomlinson commented 2 years ago

BTW, do you have access to those Dev Azure App Service? https://portal.azure.com/#@clearlydefinedoutlook.onmicrosoft.com/resource/subscriptions/e05584a1-ed97-4676-aec9-d82ba4c36c93/resourceGroups/clearlydefined-dev/providers/Microsoft.Web/sites/clearlydefined-api-dev/appServices

I don't have access to the Dev Azure App Service.
My findings are noted here and hopefully add value to whoever works on this in the future.

MichaelTsengLZ commented 2 years ago

@qtomlinson I think the issue is that locally you may use localhost:4000/definitions/go/golang/github.com%2fdgrijalva/jwt-go/v3.2.0+incompatible?matchCasing=false&preview=true which will be handled by this route. However, one dev and prod, the Cloudfare will translate that %2f in the URL to / then the original route doesn't work.

Two options:

  1. Add code in the v1.0.0 /defitions API here. And change the frontend code point to the new API.
  2. Use the same way as this route, which don't like.
qtomlinson commented 2 years ago

Agreed. Not a fan of Option 2.
The preview definition call is already a POST call. Can potentially, introduce a new API: Post: /definitions/preview Post body:

{
    "coordinates": "go/golang/github.com%2fdgrijalva/jwt-go/v3.2.0+incompatible",
    "curation": {"described": {"releaseDate": "2022-06-04"}}
}

The coordinates in the post body is currently a string (to be consistent with the rest of the apis), but can be extended to an object if necessary in the future. This is an additional API in definitions, not in conflict with any exiting API, and therefore no need for api versioning here.

bduranc commented 1 year ago

I can confirm the issue and behavior originally described by Nell is still reproducible. Not yet fixed. https://clearlydefined.io/definitions/go/golang/github.com%2fdgrijalva/jwt-go/v3.2.0+incompatible