Repository navigation
fix(integrations): validate grafana, posthog #10173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+783
−506
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7b3d5da
fix(integrations): validate grafana, posthog
waleedlatif1 ce48a58
fix(posthog): type the delete feature flag result as a tool response
waleedlatif1 08dfd77
fix(integrations): apply rollout to filter groups, require a panels a…
waleedlatif1 b5e3378
fix(integrations): apply only a real posthog rollout percentage and k…
waleedlatif1 1e5dc8d
fix(posthog): reject an invalid rollout percentage and leave create r…
waleedlatif1 5a5e816
test(posthog): use the shared jsonResponse helper
waleedlatif1 0cece63
chore(integrations): regenerate artifacts after rebase
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { createDashboardTool } from '@/tools/grafana/create_dashboard' | ||
| import type { GrafanaCreateDashboardParams } from '@/tools/grafana/types' | ||
|
|
||
| const baseParams: GrafanaCreateDashboardParams = { | ||
| apiKey: 'test-key', | ||
| baseUrl: 'https://grafana.example.com', | ||
| title: 'Service overview', | ||
| } | ||
|
|
||
| const buildBody = (params: GrafanaCreateDashboardParams) => { | ||
| const body = createDashboardTool.request.body | ||
| if (!body) throw new Error('create dashboard has no request body') | ||
| return body(params) as { dashboard: { panels: unknown } } | ||
| } | ||
|
|
||
| describe('grafana create dashboard panels', () => { | ||
| it('refuses invalid panels JSON instead of creating an empty dashboard', () => { | ||
| expect(() => buildBody({ ...baseParams, panels: '[{"type": "timeseries"' })).toThrow( | ||
| 'Invalid JSON for panels parameter' | ||
| ) | ||
| }) | ||
|
|
||
| it('creates an empty dashboard for blank panels', () => { | ||
| expect(buildBody({ ...baseParams, panels: ' ' }).dashboard.panels).toEqual([]) | ||
| }) | ||
|
|
||
| it('refuses panels JSON that is not an array', () => { | ||
| expect(() => buildBody({ ...baseParams, panels: '{"type": "timeseries"}' })).toThrow( | ||
| 'panels must be a JSON array' | ||
| ) | ||
| }) | ||
|
|
||
| it('sends panels a block reference already resolved to an array', () => { | ||
| const panels = [{ type: 'timeseries', title: 'Latency' }] | ||
| const body = buildBody({ ...baseParams, panels: panels as unknown as string }) | ||
| expect(body.dashboard.panels).toEqual(panels) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.