loopback icon indicating copy to clipboard operation
loopback copied to clipboard

500 error: Angular template GET requests treated as API calls

Open seanbrookes opened this issue 12 years ago • 4 comments

After updating to ver 1.5.3 I can't seem to load my Angularjs html templates.

These were previously loading fine using ver 1.4.1 via Angular module initialization. The files live in the /client/www/ directory which is configured in app.js to be a static folder

When I try to load a page in my app I see a series of 500 errors in my console:

Error: ORA-00942: table or view does not exist

GET /modules/dealer/templates/dealerdetail.html 500 488ms
Error: ORA-00942: table or view does not exist

GET /modules/dealer/templates/dealer.main.html 500 737ms
Error: ORA-00942: table or view does not exist

GET /modules/location/templates/address.lookup.html 500 971ms
Error: ORA-00942: table or view does not exist

GET /modules/location/templates/location.directive.template.html 500 972ms
Error: ORA-00942: table or view does not exist

GET /modules/location/templates/find.me.html 500 1459ms
Error: ORA-00942: table or view does not exist

GET /modules/location/templates/current.location.html 500 1696ms
Error: ORA-00942: table or view does not exist

GET /modules/location/templates/location.history.html 500 1448ms
Error: ORA-00942: table or view does not exist

GET /modules/location/templates/map.view.html 500 1203ms
Error: ORA-00942: table or view does not exist

GET /modules/search/templates/search.directive.template.html 500 1448ms
Error: ORA-00942: table or view does not exist

GET /modules/profile/templates/profile.main.html 500 1698ms
Error: ORA-00942: table or view does not exist

GET /modules/home/templates/home.template.html 500 1455ms
Error: ORA-00942: table or view does not exist

GET /modules/home/templates/home.app.template.html 500 1219ms

seanbrookes avatar Jan 24 '14 06:01 seanbrookes

If I roll this change back in loopback.js it starts working again:

-    if(ModelCtor) {
 +    // Only auto attach if the model doesn't have an explicit data source
 +    if(ModelCtor && (!(ModelCtor.dataSource instanceof DataSource))) {

fwiw I tried rolling the version of LB back to 1.4.1 in my package.json and re-installing from npm but it didn't roll the change back

seanbrookes avatar Jan 24 '14 06:01 seanbrookes

The fix was to make sure the model defs are all pointing to the correct data source.

In this case my accessTokens model was pointing at my oracle db instance instead of the memory db:

from models.json:

  "accessToken": {
    "dataSource": "db",

seanbrookes avatar Jan 24 '14 07:01 seanbrookes

We should error earlier so this is less confusing. I'm not sure you found the root of the problem but rather a different path to working code.

Your access token model should be able to point to any valid db data source.

@raymondfeng any additional thoughts here?

I would expect a large config error before runtime errors if something wasn't configured properly.

ritch avatar Jan 24 '14 17:01 ritch

+1 to validate models.json/datasources.json to report issues.

FYI, there were a few issues tangled in this case:

  1. The models that are auto-attached to the default DB data source
  2. The models that are explicitly configured to use the oracleDB data source
  3. There were two data sources configured with defaultForType: "db"
  4. There were another user model in addition to the one from LB and Oracle had the wrong user table created

raymondfeng avatar Jan 24 '14 17:01 raymondfeng