Skip to content

Incorrect function argument leads to undefined method 'size' #41

Description

@keestux

The bug was introduced in this commit: 0b0a72f right before v3.8.0 was created.

There are two uses of full_field_name and only one was corrected modified in that commit. The remaining full_field_name that needs fixing is at line 114 lib/fit4ruby/FitMessageRecord.rb

        field_name = field_description.full_field_name(fit_entity)

That should have been

        field_name = field_description.full_field_name(fit_entity.top_level_record.developer_data_ids)

Still that is not enough to be able to read FIT files of my Wahoo device. The following problem area is here in lib/fit4ruby/FieldDescription.rb:

      app_id = developer_data_ids[@developer_data_index].application_id
      # Convert the byte array with the app ID into a 16 character hex string.
      app_id_str = app_id.map { |i| '%02X' % i }.join('')
      @full_field_name =
        "#{@field_name.gsub(/[^A-Za-z0-9_]/, '_')}_#{app_id_str}"

The thing is, my Wahoo device does not have a application_id.
I'm not sure what the best solution is. I've replaced the code with

      if (app_id = developer_data_ids[@developer_data_index].application_id)
        # Convert the byte array with the app ID into a 16 character hex string.
        id_str = app_id.map { |i| '%02X' % i }.join('')
        @full_field_name =
            "#{@field_name.gsub(/[^A-Za-z0-9_]/, '_')}_#{id_str}"
      elsif (manf_id = developer_data_ids[@developer_data_index].manufacturer_id)
        id_str = '%02X' % manf_id
        @full_field_name = @field_name
      else
        id_str = ""
        @full_field_name = @field_name
      end

At least I can now read my FIT file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions