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

SchemaController.getAllClasses accepts parameter with wrong type #7677

Open
4 tasks done
ThornWu opened this issue Nov 4, 2021 · 3 comments
Open
4 tasks done

SchemaController.getAllClasses accepts parameter with wrong type #7677

ThornWu opened this issue Nov 4, 2021 · 3 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@ThornWu
Copy link
Contributor

ThornWu commented Nov 4, 2021

New Issue Checklist

Issue Description

When I was reading the source code, I found two mistakes when calling SchemaController.getAllClasses.

getAllClasses accepts a object with a key named clearCache.

getAllClasses(options: LoadSchemaOptions = { clearCache: false })

But there are two places calling this function with a boolean value.

No.1

In src/Routers/SchemasRouter.js#L19

function getAllSchemas(req) {
  return req.config.database
    .loadSchema({ clearCache: true })
    .then(schemaController => schemaController.getAllClasses(true)) // => #L19
    .then(schemas => ({ response: { results: schemas } }));
}

No.2

In /src/GraphQL/loaders/schemaQueries.js#L63

  const schema = await config.database.loadSchema({ clearCache: true });
  return (await schema.getAllClasses(true)).map(parseClass => ({  // => #L63
    name: parseClass.className,
    schemaFields: transformToGraphQL(parseClass.fields),
  }));

Environment

Server

  • Parse Server version: 5.0.0-beta.1

Logs

n/a

@parse-github-assistant
Copy link

Thanks for opening this issue!

  • ❌ Please edit your post and use the provided template when creating a new issue. This helps everyone to understand your post better and asks for essential information to quicker review the issue.

@mtrezza
Copy link
Member

mtrezza commented Nov 4, 2021

It seems you are correct; in 0a6eaf3 the bool has been replaced by object, but the lines you mentioned seem to have been forgotten while others were converted.

What was the potential impact of that? Tests usually pass.

@mtrezza mtrezza added severity:medium type:bug Impaired feature or lacking behavior that is likely assumed labels Nov 4, 2021
@ThornWu
Copy link
Contributor Author

ThornWu commented Nov 5, 2021

When our team switch our deploy method from docker-compose to helm chart(with a single pod), we found the hot reload of schema is broken. The database is updated, but the schema cache not. Then I found GET /schemas seems to designed for getting the newest schema by refreshing cache, so I was going to call this router manually. The only thing I need to first is adding a patch to the function getAllSchemas. I did it and it was working.

Currently I have no time to find the exact reason why the helm chart way is broken, but I ensure all PARSE config are same.

So the actual problem I met is in some case, schema cache doesn't refresh. I just bypassed the problem and found these two mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

2 participants