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

fix: Crash when using ParseQuery include with anonymous access #389

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Werkezeugs
Copy link
Contributor

Improved fix for this PR

#388

… on using .Include in ParseQueries with an anonym access
Copy link

parse-github-assistant bot commented May 30, 2024

Thanks for opening this pull request!

  • ❌ Please link an issue that describes the reason for this pull request, otherwise your pull request will be closed. Make sure to write it as Closes: #123 in the PR description, so I can recognize it.

@mtrezza
Copy link
Member

mtrezza commented May 31, 2024

Could you please add a test for this bug?

@Werkezeugs
Copy link
Contributor Author

Hi @mtrezza ,

not 100% sure how I can design a valid test for this problem.
So here some pseudo code to demonstrate the issue. may u can help to find a way to integrate this test?

//Prepare
ParseObject blog = new ParseObject("Blog");
blog["title"] = "My blog";
ParseObject comment = new ParseObject("Comment");
comment["Blog"] = blog;
await comment.SaveAsync();

//Test
var query = ParseClient.Instance.GetQuery<Comment>().Include("Blog");
var results = await query.FindAsync(CancellationToken.None);
List<Comment> items = results.ToList();

Problem:

The var results will be ok, but when casting to the var items list it throws an exception

@@ -112,6 +112,7 @@ public ParseObject Instantiate(string className, IServiceHub serviceHub)
Classes.TryGetValue(className, out ParseObjectClass info);
Mutex.ExitReadLock();

serviceHub = serviceHub ?? ParseClient.Instance;
Copy link
Member

@mtrezza mtrezza Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks suspicious. Why don't we just always use ParseClient.Instance if we know it cannot be null? What is the diff between serviceHub and ParseClient.Instance?

@mtrezza
Copy link
Member

mtrezza commented Jun 11, 2024

@Werkezeugs I looked at the tests and they are not very extensive, no e2e and a lot of mocking is missing, like obj saving. If you cannot add a test and cannot add the mocks, then we can merge without a test.

@mtrezza mtrezza changed the title Hotfix Add null check before using .Bind(serviceHub) to prevent crash on using .Include in ParseQueries (anonym access) fix: crash when using in ParseQuery include with anonymous access Jun 11, 2024
Copy link

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant bot changed the title fix: crash when using in ParseQuery include with anonymous access fix: Crash when using in ParseQuery include with anonymous access Jun 11, 2024
@mtrezza mtrezza changed the title fix: Crash when using in ParseQuery include with anonymous access fix: Crash when using ParseQuery include with anonymous access Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants