Guid.Parse throw exception about invalid format, but Guid.TryParse returns true

Volodymyr Shelest 0 Reputation points
2023-09-10T16:17:57.23+00:00

Hello,

I'm working with gRPC technology and now have a weird problem with Guid.Parse method.

First of all, you can see the source code of my project here. The problem is in WebAPI service, Database Info Service responses. TableService.GetByDatabaseAsync is what I've tested and the end stack trace is in AttributeMapper when the program parses attribute id.

I'm trying to fix the problem myself, so lines in StackTrace could be different with the lines from source code in GitLab.

I've attached 2 screenshots:

  • The logs from docker container
  • Code that generate these logs

As you can see Guid.TryParse says that guid is good

But when I parse with Guid.Parse method, I've got such exception.

The Guid is generated with Guid.NewGuid() and has been written to postgres db

User's image

User's image

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,563 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,944 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. P a u l 10,731 Reputation points
    2023-09-10T17:51:06.7166667+00:00

    Are you sure it's not one of the other two Guid.Parse calls you're making in that method?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.