Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_isValidMeasurement mistake #3014

Closed
HNTQ opened this issue Nov 10, 2022 · 0 comments · Fixed by #3750
Closed

_isValidMeasurement mistake #3014

HNTQ opened this issue Nov 10, 2022 · 0 comments · Fixed by #3750
Assignees
Labels
Bug Verified Bug reported, reproducible, and verified.

Comments

@HNTQ
Copy link

HNTQ commented Nov 10, 2022

Hello,

Bug Report

Describe the Bug

There is an issue to _isValidMeasurement function.
It will never return false because return is inside forEach loop.

_isValidMeasurement(measurementData) {
Object.keys(measurementData).forEach(key => {
if (!MEASUREMENT_SCHEMA_KEYS.includes(key)) {
log.warn(`Invalid measurement key: ${key}`);
return false;
}
});
return true;
}

This function is used inside addRawMeasurement function

if (!this._isValidMeasurement(measurement)) {
log.warn(
`Attempting to add or update a invalid measurement provided by '${sourceInfo}'. Exiting early.`
);
return;
}

The warn is never prompt in console and function continue and add measurement:

image

One possible solution:

       _isValidMeasurement(measurementData) {
        const _isValidKey = key => MEASUREMENT_SCHEMA_KEYS.includes(key)
    
        return Object.keys(measurementData).every(key => {
          if (!_isValidKey(key)) {
            log.warn(`Invalid measurement key: ${key}`);
            return false;
          }
          return true;
        });
      }
@james-hanks james-hanks added the Awaiting Reproduction Can we reproduce the reported bug? label Oct 25, 2023
@jbocce jbocce added Bug Verified Bug reported, reproducible, and verified. and removed Awaiting Reproduction Can we reproduce the reported bug? labels Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Verified Bug reported, reproducible, and verified.
Projects
None yet
4 participants