hydra-client-go
hydra-client-go copied to clipboard
Incorrect Logic in OAuth2Client.HasMetadata()
Preflight checklist
- [X] I could not find a solution in the existing issues, docs, nor discussions.
- [X] I agree to follow this project's Code of Conduct.
- [X] I have read and am following this repository's Contribution Guidelines.
- [ ] I have joined the Ory Community Slack.
- [ ] I am signed up to the Ory Security Patch Newsletter.
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
- 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 */ },
}
- Next, call the HasMetadata() method on this instance to check if the metadata is considered set:
hasMeta := client.HasMetadata()
- 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
}