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

Incorrect Logic in OAuth2Client.HasMetadata() #21

Open
3 of 5 tasks
chrutzer opened this issue Mar 1, 2024 · 0 comments
Open
3 of 5 tasks

Incorrect Logic in OAuth2Client.HasMetadata() #21

chrutzer opened this issue Mar 1, 2024 · 0 comments
Labels
bug Something is not working.

Comments

@chrutzer
Copy link

chrutzer commented Mar 1, 2024

Preflight checklist

Ory Network Project

No response

Describe the bug

The HasMetadata() function in OAuth2Client isn't working right. It should tell us with a true if there's stuff in the Metadata field. But, it's doing the opposite. It's supposed to say true when there's something in Metadata, not when it's empty.

Reproducing the bug

  1. Start by creating an OAuth2Client instance with some data in the Metadata field. For example:
client := OAuth2Client{
    Metadata: &Metadata{ /* Assume this is correctly initialized with data */ },
}
  1. Next, call the HasMetadata() method on this instance to check if the metadata is considered set:
hasMeta := client.HasMetadata()
  1. Check the result of hasMeta. Despite having filled the Metadata field in step 1, you'll surprisingly find hasMeta is false.
fmt.Println("Does client have metadata:", hasMeta) // Expected: true, Actual: false

Relevant log output

No response

Relevant configuration

No response

Version

v2.2.0

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Kubernetes

Additional Context

Obvious bug in the current implementation:

func (o *OAuth2Client) HasMetadata() bool {
	if o != nil && IsNil(o.Metadata) {
		return true
	}

	return false
}
@chrutzer chrutzer added the bug Something is not working. label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

1 participant