ory / ory/hydra-client-ruby

authorization_code_grant_access_token_lifespan cannot be nil

Open
#6 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Ruby
Stars
7
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Preflight checklist
Ory Network Project

No response

Describe the bug

Please revert back custom attribute writer methods for OAuth2Client. If records already exist cannot update and recieve ArgumentError: authorization_code_grant_access_token_lifespan cannot be nil. Those attributes are optional and new implementation is wrong when they are nil:

def authorization_code_grant_access_token_lifespan=(authorization_code_grant_access_token_lifespan)
      if authorization_code_grant_access_token_lifespan.nil?
        fail ArgumentError, 'authorization_code_grant_access_token_lifespan cannot be nil'
      end

      pattern = Regexp.new(/^([0-9]+(ns|us|ms|s|m|h))*$/)
      if authorization_code_grant_access_token_lifespan !~ pattern
        fail ArgumentError, "invalid value for \"authorization_code_grant_access_token_lifespan\", must conform to the pattern #{pattern}."
      end

      @authorization_code_grant_access_token_lifespan = authorization_code_grant_access_token_lifespan
    end

The correct implementation from version 2.2.0:

    # Custom attribute writer method with validation
    # @param [Object] authorization_code_grant_access_token_lifespan Value to be assigned
    def authorization_code_grant_access_token_lifespan=(authorization_code_grant_access_token_lifespan)
      pattern = Regexp.new(/^([0-9]+(ns|us|ms|s|m|h))*$/)
      if !authorization_code_grant_access_token_lifespan.nil? && authorization_code_grant_access_token_lifespan !~ pattern
        fail ArgumentError, "invalid value for \"authorization_code_grant_access_token_lifespan\", must conform to the pattern #{pattern}."
      end

      @authorization_code_grant_access_token_lifespan = authorization_code_grant_access_token_lifespan
    end
Reproducing the bug

Make Api request set_o_auth2_client for an existing record

Relevant log output

No response

Relevant configuration

No response

Version

2.2.1

On which operating system are you observing this issue?

macOS

In which environment are you deploying?

Docker

Additional Context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the OAuth2Client custom attribute writer for authorization_code_grant_access_token_lifespan and compare it with the version 2.2.0 implementation shown in the issue. Reproduce the existing-record set_o_auth2_client request, then verify that nil is accepted while non-nil invalid values are still rejected.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.