fix(notebooks): bind sample notebook paragraphs to the selected data - #2865
fix(notebooks): bind sample notebook paragraphs to the selected data#2865cnoramut wants to merge 3 commits into
Conversation
…source (opensearch-project#2454) Add sample notebooks collected the data source chosen in its modal and passed it to the sample data install, but dropped it before creating the notebooks. main.tsx posted only visIds, and addSampleNotes accepted only visIds, so the generated paragraphs carried no dataSourceMDSId or dataSourceMDSLabel. The per-paragraph selector gates defaultOption on paradataSourceMDSId !== undefined, so with nothing stored it fell through to handleDefaultDataSource and resolved the configured default data source instead. The sample data landed on the picked cluster while the notebook that reads it pointed somewhere else, so on a multi-cluster setup the PPL and SQL paragraphs query a cluster that has no sample indices. Thread the id and label from the modal through the route into addSampleNotes, which stamps both onto every paragraph before create. Stamped in addSampleNotes rather than in the four builder functions inside sample_notebooks.ts, which keeps that 1237-line file untouched. Both fields fall back to the empty string when nothing is selected, and that fallback is load-bearing rather than cosmetic. notebook.tsx blanks a QUERY paragraph's output and raises a danger toast when dataSourceMDSId is truthy while multiple data sources are disabled. Local cluster's id is already the empty string, so Local cluster and non-MDS installs keep their existing code path. Complementary to PR 2861 rather than dependent on it. That fix covers the Local cluster path with multiple data sources enabled, which is a different case from the real-data-source path this change addresses. Signed-off-by: Chayanin Noramuttha <cnoramut@gmail.com>
PR Reviewer Guide 🔍(Review updated until commit 1a1bae3)Here are some key observations to aid the review process:
|
|
Persistent review updated to latest commit 098189b |
|
LGTM, just one minor finding worth adding before merge In dataSourceMDSId: schema.maybe(schema.string({ defaultValue: '' })),
dataSourceMDSLabel: schema.maybe(schema.string({ defaultValue: '' })),The The empty-string default is misleading — it reads as if the server sees Please drop the dataSourceMDSId: schema.maybe(schema.string()),
dataSourceMDSLabel: schema.maybe(schema.string()),Functionally equivalent since |
Signed-off-by: Chayanin Noramuttha <cnoramut@gmail.com>
|
Persistent review updated to latest commit 1a1bae3 |
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
Thank you. Fix with the new push. Worth flagging that |
|
Good catch, those four in paraRouter.ts (lines 129, 130, 204, 205) are the same dead default. I'd keep this PR scoped to the sample-notebook fix and clean those up in a separate PR so the back-port stays clean. |
Description
Add sample notebooksdoes not honor the data source selected in its modal. The sample data installs against the chosen data source correctly, but every code block inside the created notebooks points at whichever data source is configured as the default.Root cause. The selected id is dropped at the persistence boundary.
main.tsxposts onlyvisIds, andaddSampleNotesaccepts onlyvisIds, so the generated paragraphs are written with nodataSourceMDSIdand nodataSourceMDSLabel:The per-paragraph selector gates its
defaultOptiononparadataSourceMDSId !== undefined. With nothing stored that isfalse, soDataSourceSelectorfalls through tohandleDefaultDataSourceand resolves the default data source instead of the one picked. On a real multi-cluster setup the sample data lands on one cluster while the notebook queries another, so the PPL and SQL paragraphs hit a cluster with no sample indices.Fix. Thread the id and label from the modal through the route into
addSampleNotes, which stamps both onto every paragraph before create. The fields, the writer on paragraph run, and the reader indefault_parser.tsxall already existed. Only the sample creation path never populated them.Notes for reviewers
addSampleNoteswas written and validated red then green, can add if necessary.notebook.tsxblanks aQUERYparagraph's output and raises a danger toast whendataSourceMDSIdis truthy while multiple data sources are disabled. Local cluster's id is already the empty string, so defaulting to''keeps Local cluster and non-MDS installs on their existing path.Testing. Verified with MDS enabled inside a workspace holding a wizard-created data source. Before the fix every paragraph across all four sample notebooks had
dataSourceMDSIdanddataSourceMDSLabelnull. After, every paragraph carries the selected id and label, confirmed by querying theobservability-notebooksaved objects directly. Jest suites forpublic/components/notebooksandserverpass, lint clean.Before
Before.2454.mov
After
After.2454.mov
Issues Resolved
Fixes #2454
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.