Skip to content

Commit

Permalink
cli: prevent reading a key of undefined value from config file
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela committed Jul 13, 2023
1 parent f41f5fa commit 8071969
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/dirty-adults-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-hive/cli': patch
---

prevent reading a key of undefined value from config file
8 changes: 7 additions & 1 deletion packages/libraries/cli/src/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,18 @@ export class Config {
}
}

get<TKey extends ValidConfigurationKeys>(key: TKey): GetZodValueType<TKey, typeof ConfigModel> {
get<TKey extends ValidConfigurationKeys>(
key: TKey,
): GetZodValueType<TKey, typeof ConfigModel> | null {
const map = this.read();

const parts = key.split('.');
let current: any = map;
for (const part of parts) {
if (current == null) {
return null;
}

current = current[part];
}

Expand Down

0 comments on commit 8071969

Please sign in to comment.