Comments (1)
Hey @ThinneshHummingsoft! I'm here to help you with your bug report. I can assist you with solving bugs, answering questions, and even becoming a contributor. Let's get to the bottom of this together!
To resolve the "Unexpected error: TypeError: Cannot read properties of undefined (reading 'some')" error when adding metrics in the tree chart page of Apache Superset, ensure that the savedMetrics
and columns
props passed to the DndMetricSelect
component are properly defined and not undefined
.
The error occurs because the some
method is being called on undefined
in the coerceMetrics
function. This can happen if savedMetrics
or columns
are not properly initialized.
Here is the relevant part of the code where the error might be occurring:
const coerceMetrics = (
addedMetrics: QueryFormMetric | QueryFormMetric[] | undefined | null,
savedMetrics: Metric[],
columns: ColumnMeta[],
) => {
if (!addedMetrics) {
return [];
}
const metricsCompatibleWithDataset = ensureIsArray(addedMetrics).filter(
metric => {
if (isSavedMetric(metric)) {
return savedMetrics.some(
savedMetric => savedMetric.metric_name === metric,
);
}
if (isAdhocMetricSimple(metric)) {
return columns.some(
column => column.column_name === metric.column.column_name,
);
}
return true;
},
);
return metricsCompatibleWithDataset.map(metric => {
if (!isDictionaryForAdhocMetric(metric)) {
return metric;
}
if (isAdhocMetricSimple(metric)) {
const column = columns.find(
col => col.column_name === metric.column.column_name,
);
if (column) {
return new AdhocMetric({ ...metric, column });
}
}
return new AdhocMetric(metric);
});
};
To fix this, ensure that savedMetrics
and columns
are always defined when passed to the DndMetricSelect
component. You can add default values or checks to handle cases where these might be undefined
.
For example:
const DndMetricSelect = (props: any) => {
const { onChange, multi, datasource, savedMetrics = [], columns = [] } = props;
// ... rest of the component code
};
By providing default values ([]
for both savedMetrics
and columns
), you can prevent the some
method from being called on undefined
, thus avoiding the TypeError [1].
To continue talking to Dosu, mention @dosu.
from superset.
Related Issues (20)
- SPAM
- SPAM
- SPAM
- SPAM
- SPAM
- SPAM
- SPAM
- Default native filters values don't set correctly HOT 1
- Superset 4.0.1 - Exported CSV Contains Garbled Chinese Characters and Numbers HOT 10
- Metric datatype incorrect when swap dataset HOT 1
- It is proposed to add the feature of grouping like folders HOT 3
- TimeSeries Chart is showing Year for the January month HOT 5
- Storybook controls are out of date HOT 1
- D3_FORMATS PROBLEM HOT 5
- Request execution time jumps HOT 1
- Unexpected error HOT 2
- Failed to setup alerts and reports based pypi installation HOT 6
- 4.0.1: Alerting and reports does not take EMAIL RECIPIENTS* HOT 4
- Filter does not follow label HOT 1
- [SIP-138] Proposal for Slack file upload V2 integration for Alerts and Reports HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from superset.