Fix extractHeaderStatus to handle undefined and non-string messages (#2393)

* Fix extractHeaderStatus to handle undefined and non-string messages

* Fix unsafe casts

---------

Co-authored-by: Laurent Nguyen <languye@microsoft.com>
This commit is contained in:
Laurent Nguyen
2026-02-20 16:42:17 +01:00
committed by GitHub
parent cc26e2800e
commit 5832170b2b
3 changed files with 6 additions and 3 deletions

View File

@@ -113,7 +113,7 @@ export class ContainerSampleGenerator {
? await createMongoDocument(collection.databaseId, collection, shardKey, doc) ? await createMongoDocument(collection.databaseId, collection, shardKey, doc)
: await createDocument(collection, doc); : await createDocument(collection, doc);
} catch (error) { } catch (error) {
NotificationConsoleUtils.logConsoleError(error); NotificationConsoleUtils.logConsoleError(error instanceof Error ? error.message : String(error));
} }
}), }),
); );

View File

@@ -329,7 +329,10 @@ export class NotificationConsoleComponent extends React.Component<
} }
private static extractHeaderStatus(consoleData: ConsoleData) { private static extractHeaderStatus(consoleData: ConsoleData) {
return consoleData?.message.split(":\n")[0]; if (!consoleData?.message || typeof consoleData.message !== "string") {
return undefined;
}
return consoleData.message.split(":\n")[0];
} }
private onConsoleWasExpanded = (): void => { private onConsoleWasExpanded = (): void => {

View File

@@ -37,7 +37,7 @@ const requestFabricToken = async (): Promise<void> => {
scheduleRefreshFabricToken(); scheduleRefreshFabricToken();
} catch (error) { } catch (error) {
logConsoleError(error as string); logConsoleError(error instanceof Error ? error.message : String(error));
throw error; throw error;
} finally { } finally {
lastRequestTimestamp = undefined; lastRequestTimestamp = undefined;