Skip to content

fix(autorag): fix s3 button not opening file explorer#7213

Merged
openshift-merge-bot[bot] merged 5 commits intoopendatahub-io:mainfrom
daniduong:fix/autorag-s3-not-opening
Apr 13, 2026
Merged

fix(autorag): fix s3 button not opening file explorer#7213
openshift-merge-bot[bot] merged 5 commits intoopendatahub-io:mainfrom
daniduong:fix/autorag-s3-not-opening

Conversation

@daniduong
Copy link
Copy Markdown
Contributor

@daniduong daniduong commented Apr 13, 2026

https://redhat.atlassian.net/browse/RHOAIENG-57763

Description

The Bug

The FileSelector component had a spread operator ordering bug that prevented fileUploadProps.onClearClick from overriding the default clear behavior.

In the FileUpload component, onClearClick was defined after the spread operator:

<FileUpload
  {...props.fileUploadProps}  // Line 60
  // ... other props ...
  onClearClick={() => setUploadedFile(undefined)}  // Line 89 - OVERRIDES the spread!
/>

This meant that the internal onClearClick handler always took precedence, preventing consumers from customizing the clear button behavior.

Impact

In AutoragEvaluationSelect, clicking the S3 button should open the S3 file explorer, but instead it was only clearing the internal upload state because the custom onClearClick was being overridden.

The Fix

Moved onClearClick before the spread operator, allowing fileUploadProps.onClearClick to override it:

<FileUpload
  onClearClick={() => setUploadedFile(undefined)}  // Line 59 - default behavior
  {...props.fileUploadProps}  // Line 60 - can now override!
/>

Test Improvements

The existing AutoragEvaluationSelect.spec.tsx tests had a mock FileSelector that was too simplified and didn't catch this bug. The mock directly called the prop without testing the actual spread behavior.

Changes:

  • ✅ Removed the mock FileSelector - tests now use the real component
  • ✅ Updated all test selectors to use accessible queries (getByRole, getByPlaceholderText) instead of test IDs
  • ✅ Test now validates that clicking the S3 button opens the file explorer (proving the override works)

This makes the tests more realistic and catches prop ordering bugs like this one.

How Has This Been Tested?

Unit Tests:

  • ✅ All 19 tests in AutoragEvaluationSelect.spec.tsx pass (including the critical "should open S3FileExplorer when S3 button is clicked" test)
  • ✅ All tests in FileSelector.spec.tsx pass

Manual Testing:

  1. Navigate to AutoRAG configuration page
  2. In the "Evaluation data" section, click the S3 button
  3. Verify the S3 file explorer modal opens ✅
  4. Select a file from S3 and verify it's set as the test data ✅
Screen.Recording.2026-04-13.at.10.18.31.AM.mov

Test Impact

  • Modified: packages/autorag/frontend/src/app/components/configure/__tests__/AutoragEvaluationSelect.spec.tsx

    • Removed mock FileSelector implementation
    • Updated all selectors to use accessible queries
    • All 19 tests pass with the real component
  • No changes needed: packages/autorag/frontend/src/app/components/common/__tests__/FileSelector.spec.tsx

    • Existing tests already cover the FileUpload component behavior
    • All tests continue to pass
  • Modified: packages/autorag/frontend/src/app/components/common/FileSelector.tsx

    • Reordered onClearClick prop placement (non-breaking change, improves API)

Request review criteria:

Self checklist (all need to be checked):

  • The developer has manually tested the changes and verified that the changes work
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has added tests or explained why testing cannot be added (unit or cypress tests for related changes)
  • The code follows our Best Practices (React coding standards, PatternFly usage, performance considerations)

If you have UI changes:

  • Included any necessary screenshots or gifs if it was a UI change.
  • Included tags to the UX team if it was a UI/UX change.

After the PR is posted & before it merges:

  • The developer has tested their solution on a cluster by using the image produced by the PR to main

Summary by CodeRabbit

  • Documentation

    • Updated default AutoML managed-pipeline naming prefixes documented for time-series and tabular model training pipelines used during pipeline discovery operations.
  • Refactor

    • Reorganized FileSelector component event handler prop placement for improved code structure.
  • Tests

    • Enhanced FileSelector tests by removing mock dependencies and transitioning assertions from test-ID queries to accessibility-based DOM queries, reducing test brittleness and improving reliability.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 13, 2026

Warning

Rate limit exceeded

@nickmazzi has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 34 minutes and 3 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 34 minutes and 3 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: f48140e9-90e2-4020-a0c7-fe6571951389

📥 Commits

Reviewing files that changed from the base of the PR and between fca7c43 and 79a0233.

📒 Files selected for processing (1)
  • packages/autorag/frontend/src/app/components/configure/__tests__/AutoragEvaluationSelect.spec.tsx
📝 Walkthrough

Walkthrough

Three files updated: documentation for AutoML pipeline name prefix defaults, FileSelector component prop placement adjustment, and test assertions for AutoragEvaluationSelect. The AutoML documentation changed time-series and tabular pipeline name prefix defaults from shorter to longer namespace variants. The FileSelector component moved the onClearClick handler prop position within JSX without altering functionality. The AutoragEvaluationSelect test suite removed FileSelector mock dependencies and replaced test ID assertions with accessibility-based DOM queries (placeholder text, display value, role/name patterns).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: addressing S3 button functionality in autorag, which aligns with the primary code change in FileSelector.tsx.
Description check ✅ Passed PR description is comprehensive, well-structured, and addresses all required template sections with detailed explanations of the bug, fix, testing, and impact.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/autorag/frontend/src/app/components/common/FileSelector.tsx (1)

59-60: Compose onClearClick instead of relying on prop override order.

Lines 59–60 depend on prop ordering: fileUploadProps.onClearClick replaces the local handler when provided, skipping setUploadedFile(undefined). PatternFly v6 FileUpload component recommends composing handlers—invoke local logic and then the consumer handler (if provided). This pattern ensures proper state cleanup while supporting custom actions.

Proposed change
       <FileUpload
         className="pf-v6-u-mt-sm"
-        onClearClick={() => setUploadedFile(undefined)}
-        {...props.fileUploadProps}
+        {...props.fileUploadProps}
+        onClearClick={(event) => {
+          setUploadedFile(undefined);
+          props.fileUploadProps?.onClearClick?.(event);
+        }}
         id={props.id}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/autorag/frontend/src/app/components/common/FileSelector.tsx` around
lines 59 - 60, The current FileSelector uses onClearClick={() =>
setUploadedFile(undefined)} and spreads {...props.fileUploadProps} which allows
fileUploadProps.onClearClick to override the local cleanup; instead compose the
handler so setUploadedFile(undefined) always runs then call the consumer
callback if provided: create a composedOnClearClick that calls
setUploadedFile(undefined) and then, if props.fileUploadProps?.onClearClick
exists, invokes it with the same arguments (preserving event/args), and pass
that composedOnClearClick along with the rest of props.fileUploadProps when
rendering the FileUpload component.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/autorag/frontend/src/app/components/common/FileSelector.tsx`:
- Around line 59-60: The current FileSelector uses onClearClick={() =>
setUploadedFile(undefined)} and spreads {...props.fileUploadProps} which allows
fileUploadProps.onClearClick to override the local cleanup; instead compose the
handler so setUploadedFile(undefined) always runs then call the consumer
callback if provided: create a composedOnClearClick that calls
setUploadedFile(undefined) and then, if props.fileUploadProps?.onClearClick
exists, invokes it with the same arguments (preserving event/args), and pass
that composedOnClearClick along with the rest of props.fileUploadProps when
rendering the FileUpload component.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: c15283cd-f29e-42e4-9faa-36ef7a52b230

📥 Commits

Reviewing files that changed from the base of the PR and between 8f14bce and fca7c43.

📒 Files selected for processing (3)
  • packages/automl/docs/pipeline-runs-api.md
  • packages/autorag/frontend/src/app/components/common/FileSelector.tsx
  • packages/autorag/frontend/src/app/components/configure/__tests__/AutoragEvaluationSelect.spec.tsx

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.81%. Comparing base (8f14bce) to head (79a0233).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7213      +/-   ##
==========================================
+ Coverage   64.79%   64.81%   +0.02%     
==========================================
  Files        2447     2441       -6     
  Lines       76059    76004      -55     
  Branches    19172    19159      -13     
==========================================
- Hits        49279    49259      -20     
+ Misses      26780    26745      -35     

see 19 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e464bcd...79a0233. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nickmazzi nickmazzi self-assigned this Apr 13, 2026
@nickmazzi
Copy link
Copy Markdown
Contributor

nickmazzi commented Apr 13, 2026

Works great thanks @daniduong

AI Assisted review

pr-review-7213.md

Overall Assessment

Approve — The core fix is correct, minimal, and well-explained. The test improvements are a net positive. A few minor suggestions below.

Suggestions

  1. Guard against null in container.querySelector results — Add expect(uploadInput).not.toBeNull() before the cast on lines 213, 239, 255 to produce clearer failure messages if the DOM structure changes.

  2. Consider a data-testid on the file input — Adding data-testid="file-upload-input" to the FileUpload's dropzone input (if PF supports passthrough props) would eliminate the need for container.querySelector entirely. This could be a follow-up improvement.

  3. The S3FileExplorer mock is still present — This is fine and intentional (S3FileExplorer has heavy dependencies), but worth noting that the testing improvement was targeted at FileSelector specifically.

  4. PR scope — The doc change for AutoML pipeline names is unrelated to the autorag fix. Not a problem for a small change like this, but separating unrelated doc updates into their own commit helps with git blame clarity. The current commit history already separates them (fca7c436c for the doc, a075ab4b8 for the fix, 5c4e2effa for the test), which is good.

Test Validation

autorag

Frontend ✅

Test Suites: 37 passed, 37 total
Tests:       628 passed, 628 total
Snapshots:   0 total
Time:        19.213 s, estimated 20 s

BFF ✅

go fmt ./...
go vet ./...
ok      github.com/opendatahub-io/autorag-library/bff/cmd       (cached)
ok      github.com/opendatahub-io/autorag-library/bff/internal/api      (cached)
?       github.com/opendatahub-io/autorag-library/bff/internal/config   [no test files]
?       github.com/opendatahub-io/autorag-library/bff/internal/constants        [no test files]
?       github.com/opendatahub-io/autorag-library/bff/internal/helpers  [no test files]
?       github.com/opendatahub-io/autorag-library/bff/internal/integrations     [no test files]
ok      github.com/opendatahub-io/autorag-library/bff/internal/integrations/kubernetes  (cached)
?       github.com/opendatahub-io/autorag-library/bff/internal/integrations/kubernetes/k8mocks  [no test files]
?       github.com/opendatahub-io/autorag-library/bff/internal/integrations/kubernetes/k8smocks [no test files]
?       github.com/opendatahub-io/autorag-library/bff/internal/integrations/llamastack  [no test files]
?       github.com/opendatahub-io/autorag-library/bff/internal/integrations/llamastack/lsmocks  [no test files]
?       github.com/opendatahub-io/autorag-library/bff/internal/integrations/pipelineserver      [no test files]
?       github.com/opendatahub-io/autorag-library/bff/internal/integrations/pipelineserver/psmocks     [no test files]
ok      github.com/opendatahub-io/autorag-library/bff/internal/integrations/s3  (cached)
?       github.com/opendatahub-io/autorag-library/bff/internal/integrations/s3/s3mocks  [no test files]
?       github.com/opendatahub-io/autorag-library/bff/internal/mocks    [no test files]
?       github.com/opendatahub-io/autorag-library/bff/internal/models   [no test files]
?       github.com/opendatahub-io/autorag-library/bff/internal/pipelines        [no test files]
ok      github.com/opendatahub-io/autorag-library/bff/internal/repositories     (cached)

Contract ✅

Test Suites: 1 passed, 1 total
Tests:       105 passed, 105 total
Snapshots:   0 total
Time:        2.931 s
Test Suites: 1 passed, 1 total
Tests:       105 passed, 105 total

Manual testing

Selecting a file from s3 is working now. Browse from computer has not regressed

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nickmazzi
Copy link
Copy Markdown
Contributor

Added a commit to address suggestions 1 and 2:

Null guards added — All three container.querySelector calls now have expect(uploadInput).not.toBeNull() before the cast, so if the DOM structure ever changes, the test will fail with a clear "expected not to be null" message instead of a cryptic error.

data-testid not feasible — PF's FileUpload renders the file input via react-dropzone's getInputProps() internally. There's no prop to pass a data-testid through, so container.querySelector is the correct approach here.

@nickmazzi
Copy link
Copy Markdown
Contributor

/lgtm
/approve

@chrjones-rh
Copy link
Copy Markdown
Contributor

Automated testing looks good:

image

AI-assisted review revealed no actionable items.

Manual testing looks good:
s3-working

Thanks for the quick fix @daniduong.

/lgtm
/approve

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 13, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrjones-rh, nickmazzi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [chrjones-rh,nickmazzi]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot Bot merged commit f3eccea into opendatahub-io:main Apr 13, 2026
51 of 52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants