Skip to content

getMessagesByType() fails for records from Zwift v1.83 #47

@numicator

Description

@numicator

The getMessagesByType() (and the records()) method fails when reading "record" messages from FIT files made by the new Zwift v1.83.
The error seems to be caused by Zwift now creating the messages as "FitDataMessageWithDevData", not the old "FitDataMessage". Interestingly, the first 3 messages are still "FitDataMessage", only from message 4 they are "FitDataMessageWithDevData".

Any help very much appreciated!!!

Test FIT file attached.
2025-02-06-17-45-53.zip

To reproduce:

> fit.file <- readFitFile("2025-02-06-17-45-53.fit")
> getMessagesByType(fit.file, "record")

Error in `` `*tmp*`[[i]] ``:
! Can't extract column with `i`.
✖ Subscript `i` must be a positive location, not 0.
Run `rlang::last_trace()` to see where the error occurred.

> rlang::last_trace()
<error/vctrs_error_subscript_type>
Error in `` `*tmp*`[[i]] ``:
! Can't extract column with `i`.
✖ Subscript `i` must be a positive location, not 0.
---
Backtrace:
     ▆
  1. ├─FITfileR::getMessagesByType(fit.file, "record")
  2. └─FITfileR::getMessagesByType(fit.file, "record")
  3.   ├─FITfileR::getMessagesByType(fitFile, global_message_number)
  4.   └─FITfileR::getMessagesByType(fitFile, global_message_number)
  5.     └─base::lapply(messages2, FUN = .processFieldsList, message_type)
  6.       └─FITfileR (local) FUN(X[[i]], ...)
  7.         └─FITfileR:::.processDevFieldsList(x)
  8.           ├─`*tmp*`[[i]]
  9.           └─tibble:::`[[.tbl_df`(`*tmp*`, i)
 10.             └─tibble:::tbl_subset2(x, j = i, j_arg = substitute(i))
 11.               └─tibble:::vectbl_as_col_location2(...)
 12.                 ├─tibble:::subclass_col_index_errors(...)
 13.                 │ └─base::withCallingHandlers(...)
 14.                 └─vctrs::vec_as_location2(j, n, names, call = call)
 15.                   └─vctrs:::result_get(...)
Run rlang::last_trace(drop = FALSE) to see 1 hidden frame.

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