Record Details not displaying

:warning:This is a template you must use to report issues. :warning:
You can also drag images, videos and include Preformatted text.

List view showing correctly:

Error when selecting individual record:

Feature(s) impacted

Please describe in this mandatory section the feature(s) that will be discussed in this topic.

The CRUD routes seem to all return 404 even though the list routes display details

Observed behavior

Please describe in this mandatory section the current behavior you observe.

When selecting an individual record, the api returns a 404 (Not Found).

Expected behavior

Please describe in this mandatory section the behavior you are expecting.

We’d assume the mongo record 62045768be659c3a4205f267 from collection “sources” would display

Failure Logs

In this optional section, please:

  • include any relevant log snippets if necessary,
  • or remove this section if left empty.

Context

Please provide in this mandatory section, the relevant information about your configuration:

  • Project name: Carrot Warehouse
  • Team name: Operations
  • Environment name: Development
  • Agent type & version:

“forest-express-mongoose”: “8.6.3”,

  • Recent changes made on your end if any:

Simply using the forest-express-mongoose:

import * as Forest from 'forest-express-mongoose'
import * as Mongoose from 'mongoose'

console.log('connection.modelNames', connection.modelNames())
  connection.modelNames().map((modelName) => {
    Forest.collection(modelName, {
      actions: [],
      fields: [],
      segments: [],
      fieldsToFlatten: [],
    })
  })

  const forest = await Forest.init({
    // configDir: join(__dirname, './forest/forest'),
    envSecret: process.env.FOREST_ENV_SECRET,
    authSecret: process.env.FOREST_AUTH_SECRET,
    schemaDir: process.env.FOREST_SCHEMA_DIR,
    objectMapping: Mongoose,
    includedModels: connection.modelNames(),
    // includedModels: models,
    connections: { default: connection },
  })
  app.use(forest)

Failure Logs:

chunk.8.0ef465b663b809cf1743.js:1 GET http://localhost:3310/forest/Source/62045768be659c3a4205f267?timezone=America%2FLos_Angeles 404 (Not Found)
(anonymous) @ chunk.8.0ef465b663b809cf1743.js:1
(anonymous) @ chunk.8.0ef465b663b809cf1743.js:1
send @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:48
ajax @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:48
_ajaxRequest @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:149
_ajax @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:149
(anonymous) @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:149
(anonymous) @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
x @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
ajax @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:149
(anonymous) @ client-f8c55ff26b26addedbdee95220b1137e.js:1
Promise.then (async)
ajax @ client-f8c55ff26b26addedbdee95220b1137e.js:1
findRecord @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:149
(anonymous) @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:149
v @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
(anonymous) @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
invoke @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
flush @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
flush @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
_end @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
end @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
_run @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
_join @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
join @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
h @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
(anonymous) @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
a @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
handleEvent @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
handleEvent @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
(anonymous) @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:58
dispatch @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:48
g.handle @ vendor-56f6d5c2818e6c53ba88479381c34a73.js:48
chunk.8.0ef465b663b809cf1743.js:1 [forest] :deciduous_tree::deciduous_tree::deciduous_tree: Unexpected error in details view: n {isAdapterError: true, stack: ‘Error: Ember Data Request GET http://localhost:331…m/assets/chunk.8.0ef465b663b809cf1743.js:1:45893)’, description: undefined, fileName: undefined, lineNumber: undefined, …}
(anonymous) @ chunk.8.0ef465b663b809cf1743.js:1

Hi @Anthony_Wentzel,

I’m sorry to hear that. I do not reproduce on my end.
Could you please share the mongo request that is generated ?

@vince How do I log the mongo request? Is there a debug flag?

As you can see here, it seems you just need to do:

mongoose.set('debug', true);

Ok here’s the debug:

POST /forest/authentication 200 1041 - 25.343 ms
OPTIONS /forest/authentication/callback?code=ugCk0UG1T28YHV6XyfyikeCXLPK7KYbMSCOfJcurY5eGspRYP4bmn9cBFzmFMSi7&state=%7B%22renderingId%22%3A116333%7D 200 8 - 12.838 ms
GET /forest/authentication/callback?code=ugCk0UG1T28YHV6XyfyikeCXLPK7KYbMSCOfJcurY5eGspRYP4bmn9cBFzmFMSi7&state=%7B%22renderingId%22%3A116333%7D 200 550 - 1288.225 ms
sources.aggregate [{"$group":{"_id":null,"count":{"$sum":1}}}] {}
GET /forest/Source/count?fields%5BSource%5D=_id%2CcreatedAt%2Cname%2CpublisherId%2CupdatedAt%2Curl&fields%5BpublisherId%5D=name&timezone=America%2FLos_Angeles 304 - - 1337.198 ms
sources.aggregate [{"$sort":{"_id":-1}},{"$skip":0},{"$limit":15}] {}
GET /forest/Source?timezone=America%2FLos_Angeles&fields%5BSource%5D=_id%2CcreatedAt%2Cname%2CpublisherId%2CupdatedAt%2Curl&fields%5BpublisherId%5D=name&page%5Bnumber%5D=1&page%5Bsize%5D=15&sort=-_id 304 - - 1599.601 ms
sources.aggregate [{"$match":{"$and":[{"_id":"62045768be659c3a4205f267"}]}},{"$group":{"_id":null,"count":{"$sum":1}}}] {}
GET /forest/Source/62045768be659c3a4205f267?timezone=America%2FLos_Angeles 404 113 - 1763.474 ms
sources.aggregate [{"$match":{"$and":[{"_id":"62045768be659c3a4205f267"}]}},{"$group":{"_id":null,"count":{"$sum":1}}}] {}
GET /forest/Source/62045768be659c3a4205f267?timezone=America%2FLos_Angeles 404 113 - 114.697 ms

Looks like forest-express-mongoose is not finding the records. When I tap the detail I don’t see any mongo query… it’s almost like the express route does not exist

Yo @Anthony_Wentzel :wave:

Can you share the model definition of the collection Sources ?

Yes,

import { Exclude } from 'class-transformer'
import { Model, ObjectId } from 'mongoose'

import { Field, ObjectType } from '@nestjs/graphql'
import { DocumentType, index, modelOptions, prop } from '@typegoose/typegoose'

import { BaseSchema } from '../core/data'
import { ObjectIdScalar } from '../core/utils/graphql.utils'
import { Createable, Lookupable } from '../core/utils/types.utils'

const schemaOptions = {
  collection: 'sources',
  timestamps: true,
}

// Sources are the individual streams of content that we’d be pulling from.  Publishers may have multiple sources.  Sources will need a URL from where we’ll fetch data.
// - Fields
//     - Name
//     - URL
// - Functionalities
// - Relationships
//     - Belongs to a Publisher
//     - Has many Feeds
//     - Has many Communities through Feeds

@modelOptions({
  // options: {
  //   automaticName: false,
  //   customName: (options) => `${options.schemaOptions?.collection}`,
  // },
  schemaOptions: schemaOptions,
})
@index({ url: 1 })
@ObjectType()
export class Source extends BaseSchema {
  @Field()
  @Exclude()
  @prop({ default: '' })
  public name: string

  @Field()
  @prop({ default: '' })
  public url: string

  @Field(() => ObjectIdScalar)
  @prop({ required: true, ref: 'Publisher' })
  public publisherId: ObjectId
}

export type CreateableSource = Createable<Source>
export type PartialSource = Partial<Source>
export type FetchableSource = Lookupable<Source>
export type SourceDocument = DocumentType<Source>
export type SourceModel = Model<SourceDocument>
export type SourceRepository = SourceModel

I’ve tried forcing the collection name “sources” to match the model name. But the default collection is “sources” and model name is “Source”

Would you like me to zip you the entire project to help?

Thank you!

Sure. Can you send it to me via Message?

Can you post also your BaseSchema here?
Do you encounter this issue on all your environments or only on dev?
What version of mongoose/mongo are you using?

@anon37903635 Yes, I sent you a message with link

Yup, I’m already on it :muscle:, cheers. I’ll keep you posted

Great thank you, happy to help or make whatever changes are needed.

@anon37903635 any updates here?

@Anthony_Wentzel Not yet, unfortunately :slightly_frowning_face:
I’ll reach out to some of my colleagues for their opinions on the matter.

I’ll alert you as soon as I find something :muscle::evergreen_tree:

@Anthony_Wentzel Yo :wave:

The issue is still being discussed among us.
In the meantime, here’s a couple of my leads: :mag:

  • Before performing the request against the database, are you casting the ID to ObjectId?
  • The call between the frontend and the backend targets /forest/Source? Is that correct? Shouldn’t it be /forest/sources?

You might want to take a look at this thread. :face_with_monocle:
Also, what’s the intent with this project architecture? Or what is the use case you are trying to do?

EDIT: One of our team will organize a live debug session with you, stay tuned :muscle::evergreen_tree:

Yes, I agree.

Currently, I do not downcast as the forest-express-mongoose is handling all the routes.

I’ve tried it both ways… using the actual model name and setting the collection name for the model.

forest-express-mongoose does throw a warning if we try to use the “sources” (the collection name) versus the actual model name “Source”