Skip to content

BazaRb#push leaks NoMethodError for non-String data #498

Description

@gemshrine

Symptom and impact

BazaRb#push documents data as a String, but it does not validate that type before calling String-only methods. Passing a different value raises a raw NoMethodError instead of the client's normal argument-validation error. The fake client has the same gap, so tests can fail with a different low-level exception rather than a clear input error.

Steps to reproduce

client = BazaRb.new('example.org', 443, 'token')
client.push('valid-job', 42, [])

The call fails before making an HTTP request: push reaches data.empty? with an Integer. The same input to BazaRb::Fake.new.push('valid-job', 42, []) also reaches data.empty? without a type check.

Actual result

Both clients leak NoMethodError for Integer#empty?. Callers do not get an error identifying data as the invalid argument.

Expected result

The real and fake clients should reject non-String data with a clear validation error before starting upload work, consistent with the documented String parameter and the validation of nil and empty data.

Technical evidence

lib/baza-rb.rb checks only nil and emptiness for data before passing it to File.binwrite; lib/baza-rb/fake.rb performs the same nil and emptiness checks. Neither path verifies data.is_a?(String). Existing tests cover nil and empty data but not other types.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions