Skip to content

Commit 643a2a0

Browse files
iobuhovclaude
andcommitted
fix(maps-web): check apiKeyExp existence before falling back to static apiKey
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent c8d1878 commit 643a2a0

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

packages/pluggableWidgets/maps-web/openspec/changes/archive/2026-06-17-maps-api-key-atom/specs/api-key-atom/spec.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,26 @@ The Maps container SHALL provide a `ComputedAtom<string | null>` that reactively
66

77
#### Scenario: Expression value takes priority
88

9-
- **WHEN** `apiKeyExp.value` is a non-empty string
9+
- **WHEN** `apiKeyExp` is configured (not undefined)
10+
- **AND** `apiKeyExp.value` is a non-empty string
1011
- **THEN** the atom returns that value
1112

13+
#### Scenario: Returns null while expression is loading
14+
15+
- **WHEN** `apiKeyExp` is configured (not undefined)
16+
- **AND** `apiKeyExp.value` is undefined (still loading)
17+
- **THEN** the atom returns `null`
18+
1219
#### Scenario: Falls back to static apiKey
1320

14-
- **WHEN** `apiKeyExp.value` is undefined or empty
21+
- **WHEN** `apiKeyExp` is undefined (not configured)
1522
- **AND** `apiKey` is a non-empty string
1623
- **THEN** the atom returns the static `apiKey` value
1724

1825
#### Scenario: Returns null when no key available
1926

20-
- **WHEN** both `apiKeyExp.value` and `apiKey` are empty or undefined
27+
- **WHEN** `apiKeyExp` is undefined
28+
- **AND** `apiKey` is empty or undefined
2129
- **THEN** the atom returns `null`
2230

2331
### Requirement: API key cached once resolved
@@ -45,18 +53,26 @@ The Maps container SHALL provide a `ComputedAtom<string | null>` that reactively
4553

4654
#### Scenario: Expression value takes priority
4755

48-
- **WHEN** `geodecodeApiKeyExp.value` is a non-empty string
56+
- **WHEN** `geodecodeApiKeyExp` is configured (not undefined)
57+
- **AND** `geodecodeApiKeyExp.value` is a non-empty string
4958
- **THEN** the atom returns that value
5059

60+
#### Scenario: Returns null while expression is loading
61+
62+
- **WHEN** `geodecodeApiKeyExp` is configured (not undefined)
63+
- **AND** `geodecodeApiKeyExp.value` is undefined (still loading)
64+
- **THEN** the atom returns `null`
65+
5166
#### Scenario: Falls back to static geodecodeApiKey
5267

53-
- **WHEN** `geodecodeApiKeyExp.value` is undefined or empty
68+
- **WHEN** `geodecodeApiKeyExp` is undefined (not configured)
5469
- **AND** `geodecodeApiKey` is a non-empty string
5570
- **THEN** the atom returns the static `geodecodeApiKey` value
5671

5772
#### Scenario: Returns null when no key available
5873

59-
- **WHEN** both `geodecodeApiKeyExp.value` and `geodecodeApiKey` are empty or undefined
74+
- **WHEN** `geodecodeApiKeyExp` is undefined
75+
- **AND** `geodecodeApiKey` is empty or undefined
6076
- **THEN** the atom returns `null`
6177

6278
### Requirement: Geodecode API key cached once resolved

packages/pluggableWidgets/maps-web/src/model/atoms/apiKey.atom.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export function apiKeyAtom(gate: DerivedPropsGate<MapsContainerProps>): Computed
66
let cached: string | null = null;
77
return computed(() => {
88
if (cached !== null) return cached;
9-
const value = (gate.props.apiKeyExp?.value ?? gate.props.apiKey) || null;
9+
const value =
10+
gate.props.apiKeyExp !== undefined ? gate.props.apiKeyExp.value || null : gate.props.apiKey || null;
1011
if (value) cached = value;
1112
return value;
1213
});

packages/pluggableWidgets/maps-web/src/model/atoms/geodecodeApiKey.atom.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ export function geodecodeApiKeyAtom(gate: DerivedPropsGate<MapsContainerProps>):
66
let cached: string | null = null;
77
return computed(() => {
88
if (cached !== null) return cached;
9-
const value = (gate.props.geodecodeApiKeyExp?.value ?? gate.props.geodecodeApiKey) || null;
9+
const value =
10+
gate.props.geodecodeApiKeyExp !== undefined
11+
? gate.props.geodecodeApiKeyExp.value || null
12+
: gate.props.geodecodeApiKey || null;
1013
if (value) cached = value;
1114
return value;
1215
});

0 commit comments

Comments
 (0)