Skip to content

Fix Root element is missing exception#15

Merged
wo80 merged 1 commit into
avatar29A:masterfrom
jayfunc:master
Aug 12, 2025
Merged

Fix Root element is missing exception#15
wo80 merged 1 commit into
avatar29A:masterfrom
jayfunc:master

Conversation

@jayfunc

@jayfunc jayfunc commented Aug 6, 2025

Copy link
Copy Markdown
Contributor

Hi! Thanks for your work, but I came across the error when I used this package in my WinUI 3 project with .NET 8.

I tried to get the auth URL, and it gave me an error: "Root element is missing". After forking it and locating it, the error seems like something is wrong with the Stream.

I added a few lines based on the comment below:
https://stackoverflow.com/questions/10125810/root-element-is-missing

And the error no longer exists. I also tested some other functions like getting user info and posting scrobbling, and they worked well.

I just created this pull request to make this package more stable and with fewer bugs.

Hope this helped!

@wo80

wo80 commented Aug 12, 2025

Copy link
Copy Markdown
Collaborator

Hi @jayfunc ,

sorry for the late reply. I finally had some time to take a closer look. The cause of this problem is 7f89630.

var doc = GetXDocument(stream);
var responseContainsError = ResponseParser.Default.TryParseResponseError(doc, out string message, out int error);
if (!response.IsSuccessStatusCode || responseContainsError)
{
throw new ServiceException(method, error, response.StatusCode, message ?? response.ReasonPhrase);
}
return GetXDocument(stream);
}

In the Request.PostAsync(...) method, GetXDocument(...) is called twice, while the method should just return doc. Could you delete your latest commit, do the fix and then force push, so this pull request gets updated?

Thanks for bringing this to my attention!

@jayfunc

jayfunc commented Aug 12, 2025

Copy link
Copy Markdown
Contributor Author

Hi, I have done the modification. Thank you for your response!

@wo80

wo80 commented Aug 12, 2025

Copy link
Copy Markdown
Collaborator

Thank you! I will do a patch release in the next days.

@wo80
wo80 merged commit 429e14c into avatar29A:master Aug 12, 2025
1 check passed
@wo80

wo80 commented Aug 17, 2025

Copy link
Copy Markdown
Collaborator

@jayfunc I have updated the nuget package.

@jayfunc

jayfunc commented Aug 17, 2025

Copy link
Copy Markdown
Contributor Author

@wo80 Thanks!

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