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

[Question] Why does FirebaseDatabase.GetInstance(URL) never fail except when passing in an empty or null URL? #1155

Open
MichaelPageArtrix opened this issue Nov 27, 2024 · 3 comments

Comments

@MichaelPageArtrix
Copy link

What is your question?

As the question suggest, if I pass any string at all into that function I get back a FirebaseDatabase instance.

If I try to use that instance to get a ref - the process simple hangs, no errors, no exceptions, just nothing.

That's the internal code so it seems like it thinks it could be null - but the cpp side of things seems to just new one up regardless of the URL validity.

If this is intentional - how can I check if I have a valid FirebaseDatabase instance?

      FirebaseDatabase value = null;
        string key = $"({app.Name}, {url})";
        lock (databases)
        {
            if (!databases.TryGetValue(key, out value))
            {
                InitResult init_result_out;
                InternalFirebaseDatabase instanceInternal = InternalFirebaseDatabase.GetInstanceInternal(app, url, out init_result_out);
                if (instanceInternal == null || init_result_out != 0)
                {
                    throw new DatabaseException("Failed to get FirebaseDatabase instance. Please check the log for more information.");
                }

                value = new FirebaseDatabase(app, instanceInternal);
                value.name = key;
                databases[key] = value;
            }
        }

Firebase Unity SDK Version

12.3

Unity editor version

2022.3.43f1

Installation Method

Unity Package Manager

Problematic Firebase Component(s)

Database

Other Firebase Component(s) in use

Authentication

Additional SDKs you are using

No response

Targeted Platform(s)

Apple Platforms, Android

Unity editor platform

Windows

Scripting Runtime

IL2CPP

Release Distribution Type

Pre-built SDK from https://firebase.google.com/download/unity

@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@argzdev
Copy link

argzdev commented Nov 28, 2024

Thanks for reaching out, @MichaelPageArtrix. I was able to reproduce the same behavior. It does look like when passing a null value, this error is caught:

CS0121: The call is ambiguous between the following methods or properties: 'FirebaseDatabase.GetInstance(FirebaseApp)' and 'FirebaseDatabase.GetInstance(string)'

However, no error shows up when an empty string is passed. eg. FirebaseDatabase.GetInstance("").GetReference("example");

I'll go ahead and report this to our engineers. Thanks!

@MichaelPageArtrix
Copy link
Author

Thanks for the update!

Just to be clear the error I'm coming up against is that if you pass in any string at all you get a FirebaseDatabase returned - even if that string is not a valid URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants