Skip to content

Commit ff0eb6e

Browse files
committed
fix(github): treat boolean false as an explicit gist visibility choice
1 parent 10f9da7 commit ff0eb6e

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

‎apps/sim/blocks/blocks/github.param-wiring.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,27 @@ describe('gist_public coercion', () => {
9595
expect(map({ operation: 'github_create_gist' })).not.toHaveProperty('public')
9696
})
9797

98+
it.each([null, undefined, ''])('treats %o as unset rather than Secret', (unset) => {
99+
expect(map({ gist_public: unset })).not.toHaveProperty('public')
100+
})
101+
102+
/**
103+
* The block declares this input as `boolean`, so a writer following that
104+
* schema stores `false` rather than the dropdown's `'false'`. Both mean the
105+
* user chose Secret, and a truthy presence check would silently drop one of
106+
* them — letting a model-supplied `public: true` through on the agent path.
107+
*/
108+
it.each([
109+
['false', false],
110+
[false, false],
111+
])('treats %o as an explicit Secret selection', (input, expected) => {
112+
expect(map({ gist_public: input }).public).toBe(expected)
113+
})
114+
115+
it.each(['false', false])('overrides a model-supplied public for %o', (secret) => {
116+
expect({ public: true, ...map({ gist_public: secret }) }.public).toBe(false)
117+
})
118+
98119
it('matches the dropdown option ids the block actually renders', () => {
99120
const sub = GitHubBlock.subBlocks.find((s) => s.id === 'gist_public')
100121
expect(sub?.options).toBeDefined()

‎apps/sim/blocks/blocks/github.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2316,8 +2316,20 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
23162316
* 'true'/'false' while the tool declares `public` as a boolean. The
23172317
* generic handler only JSON-parses `json`/`array` inputs, so nothing
23182318
* else coerces it.
2319+
*
2320+
* Presence is tested rather than truthiness, because boolean `false` is
2321+
* a real selection: the block declares this input as `boolean`, so a
2322+
* writer following that schema stores `false` rather than `'false'`.
2323+
* Under a truthy check the two disagree — `'false'` would force the
2324+
* gist secret while `false` was dropped, letting a model-supplied
2325+
* `public: true` through on the agent path. Only an unset field
2326+
* (nullish or empty) defers to the tool's own default.
23192327
*/
2320-
if (params.gist_public) {
2328+
if (
2329+
params.gist_public !== undefined &&
2330+
params.gist_public !== null &&
2331+
params.gist_public !== ''
2332+
) {
23212333
result.public = params.gist_public === true || params.gist_public === 'true'
23222334
}
23232335

0 commit comments

Comments
 (0)