Skip to content

Corsfilter fix#12151

Open
beepsoft wants to merge 21 commits intoIQSS:developfrom
beepsoft:cors-filter-fix
Open

Corsfilter fix#12151
beepsoft wants to merge 21 commits intoIQSS:developfrom
beepsoft:cors-filter-fix

Conversation

@beepsoft
Copy link
Copy Markdown
Contributor

@beepsoft beepsoft commented Feb 6, 2026

What this PR does / why we need it:

Fixes CorsFilter invocation inconsistency.

When accessing /api/... endpoints the CorsFilter was not always hit and so these endpoints could not be used from webapps even if CORS was properly configured.

The problem seemed to be with ApiRouter's forwarding mechanism from /api/... to /api/v1/...

Adding FORWARD dispatcher types to @WebFilter solves this.

Fix is based on this zulip thread:

https://dataverse.zulipchat.com/#narrow/channel/379673-dev/topic/CorsFilter.20Servlet.20Filter.20not.20discovered/near/572358009

Also fixes #12161 with docs changes made by @poikilotherm originally as PR #12162 . Preview doc changes here: https://dataverse-guide--12151.org.readthedocs.build/en/12151/installation/config.html#cross-origin-resource-sharing-cors

Suggestions on how to test this:

CorsIT.java is added to test whether CORS headers are present for both /api/... and /api/v1/... invocations. For it to pass CORS must be enabled in Dataverse, eg. by setting

DATAVERSE_CORS_ORIGIN: "*"

env for dev_dataverse in docker-compose-dev.yml

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 6, 2026

Coverage Status

coverage: 24.323%. remained the same
when pulling 36c336e on beepsoft:cors-filter-fix
into 86796a1 on IQSS:develop.

Comment thread src/test/java/edu/harvard/iq/dataverse/api/CorsIT.java Outdated
Comment thread src/test/java/edu/harvard/iq/dataverse/api/CorsIT.java Outdated
Comment thread src/main/java/edu/harvard/iq/dataverse/filter/CorsFilter.java Outdated
@poikilotherm poikilotherm added Feature: API Component: Code Infrastructure formerly "Feature: Code Infrastructure" Feature: Permissions Component: JSF Involves modifying JSF (Jakarta Server Faces) code, which is being replaced with React. Size: 3 A percentage of a sprint. 2.1 hours. SPA These changes are required for the Dataverse SPA labels Feb 6, 2026
@poikilotherm poikilotherm marked this pull request as draft February 6, 2026 14:46
Copy link
Copy Markdown
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

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

A quick review.

Comment thread src/main/java/edu/harvard/iq/dataverse/filter/CorsFilter.java
Copy link
Copy Markdown
Collaborator

@ErykKul ErykKul left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks! Just a release note and it's ready.

@beepsoft
Copy link
Copy Markdown
Contributor Author

beepsoft commented Feb 9, 2026

@ErykKul Should I just add doc/release-notes/cors-filter-fix.md? I don't have an associated issue and so my branch name is not prefixed with the issue number, which seems to be required by the doc/release-notes/README.md

@cmbz cmbz added the FY26 Sprint 16 FY26 Sprint 16 (2026-01-28 - 2026-02-11) label Feb 11, 2026
@poikilotherm
Copy link
Copy Markdown
Contributor

poikilotherm commented Feb 11, 2026

@beepsoft Please feel free to create an issue and link this PR to it. Can be brief.

Also, I see Jenkins is not happy with one IT: [ERROR] Failures: ", "[ERROR] SwordIT.testDeleteFiles:961 1 expectation failed.", "Expected status code <200> but was <500>."

Can you please look into that? Thx!

Also, CorsIT must be added to https://github.com/IQSS/dataverse/blob/develop/tests/integration-tests.txt

@poikilotherm poikilotherm moved this from WIP to Important in Forschungszentrum Jülich Feb 11, 2026
@cmbz cmbz added the FY26 Sprint 17 FY26 Sprint 17 (2026-02-11 - 2026-02-25) label Feb 11, 2026
@beepsoft
Copy link
Copy Markdown
Contributor Author

Do we need an issue at this point? I only raised the issue question because the release note authoring README.md mentioned, but I don't know if and how that applies here.

Regarding SwordIT: I could not reproduce it locally.

I added CorsIT to integration-tests.txt.

Comment thread tests/integration-tests.txt Outdated
@poikilotherm
Copy link
Copy Markdown
Contributor

I see in https://jenkins.dataverse.org/blue/organizations/jenkins/IQSS-Dataverse-Develop-PR/detail/PR-12151/7/tests that the tests now run, but CorsIT fails - the headers are all not present.

I have a hunch that we might need @donsizemore to enable CORS during testing. Unfortunately, we currently have no way to change JVM options at runtime (there may exist an issue about this already).

@pdurbin WDYT should we disable these tests until we figure out the remote JVM option part? Can we just enable CORS in Jenkins without affecting other tests?

@qqmyers
Copy link
Copy Markdown
Member

qqmyers commented Feb 13, 2026

FWIW: I've recently started making non-IT tests with direct (mocked) calls to API methods to be able to test non-default JVM options, e.g. in LDNInboxTest.java and LocalContextsTest.java. Is that a useful approach here?

@pdurbin pdurbin moved this from Ready for QA ⏩ to Ready for Review ⏩ in IQSS Dataverse Project Feb 17, 2026
@pdurbin
Copy link
Copy Markdown
Member

pdurbin commented Feb 17, 2026

There seem to be some open questions and some failing tests and the PR is still in draft so I moved it from "ready for QA" to "ready for review".

@pdurbin
Copy link
Copy Markdown
Member

pdurbin commented Feb 24, 2026

@ErykKul Should I just add doc/release-notes/cors-filter-fix.md? I don't have an associated issue and so my branch name is not prefixed with the issue number, which seems to be required by the doc/release-notes/README.md

@beepsoft doc/release-notes/cors-filter-fix.md is fine. Also, please click "ready for review" (if you're ready), to take this PR out of draft.

@cmbz cmbz added the FY26 Sprint 21 FY26 Sprint 21 (2026-04-08 - 2026-04-22) label Apr 8, 2026
@srmanda-cs
Copy link
Copy Markdown

https://jenkins.dataverse.org/job/IQSS-Dataverse-Develop-PR/job/PR-12151/16/testReport/

CorsIT tests pass, pipeline back to normal

@pdurbin pdurbin assigned beepsoft and unassigned donsizemore Apr 9, 2026
@beepsoft
Copy link
Copy Markdown
Contributor Author

Thank you all for the work you put into this. Sorry I couldn’t be involved over the past few weeks. Is there anything else I need to do on this, or can we go ahead and close the issue?

@srmanda-cs
Copy link
Copy Markdown

srmanda-cs commented Apr 10, 2026

Thank you all for the work you put into this. Sorry I couldn’t be involved over the past few weeks. Is there anything else I need to do on this, or can we go ahead and close the issue?

Hi. Thank you for your work on this too! From my side, I would very strongly recommend you to rewrite the assertions for CorsIT as I mentioned in my earlier review. Installations like to run the test suites again, and if they set their CORS allowance policies to "*" then, CorsIT would fail and they wouldn't be able to figure out why. I know this because it is the exact same thing that happened with me ;)

Once again though, amazing work from everyone.

@pdurbin
Copy link
Copy Markdown
Member

pdurbin commented Apr 10, 2026

@beepsoft is CORS on or off by default as of this PR? Please see my confusion over the docs: #12151 (comment)

@pdurbin
Copy link
Copy Markdown
Member

pdurbin commented Apr 10, 2026

Copy link
Copy Markdown
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

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

I zoomed with @poikilotherm and he resolved my remaining issues with the docs in 2cac1fe (thanks!). API tests are passing. (Heads up to @srmanda-cs that, like Jenkins, we'll need to configure containers to turn on CORS for the CORS IT tests to pass.) I'm approving this. Thanks, all!

@github-project-automation github-project-automation Bot moved this from In Review 🔎 to Ready for QA ⏩ in IQSS Dataverse Project Apr 14, 2026
@pdurbin pdurbin moved this from Ready for QA ⏩ to In Review 🔎 in IQSS Dataverse Project Apr 15, 2026
@poikilotherm
Copy link
Copy Markdown
Contributor

poikilotherm commented Apr 15, 2026

@pdurbin Why was this assigned back to us all? I'm not sure what's missing. I'm a bit puzzled what the goal is with Jenkins tests and all...

@pdurbin
Copy link
Copy Markdown
Member

pdurbin commented Apr 15, 2026

@pdurbin Why was this assigned back to us all? I'm not sure what's missing. I'm a bit puzzled what the goal is with Jenkins tests and all...

@poikilotherm please see #12151 (comment) and #dev > CorsFilter Servlet Filter not discovered @ 💬

@beepsoft
Copy link
Copy Markdown
Contributor Author

@pdurbin Why was this assigned back to us all? I'm not sure what's missing. I'm a bit puzzled what the goal is with Jenkins tests and all...

The same applies to me. If there are any pending failures for @srmanda-cs or others in their environments, a fix is welcome, but I cannot commit to checking all possible test environments. This issue was supposed to be just about five lines of changes in CorsFilter.java 🙂

Due to our test infrastructure, it's not easy to do assertions on the content of the headers. Also, for the issue fixed in the CORS filter, this test doesn't need to check the content, just make sure they are present.
@pdurbin
Copy link
Copy Markdown
Member

pdurbin commented Apr 16, 2026

@beepsoft the conversation is happening here: https://dataverse.zulipchat.com/#narrow/channel/379673-dev/topic/CorsFilter.20Servlet.20Filter.20not.20discovered/near/585851791

@poikilotherm seems to have pushed a fix at ed07f96 so I'm unassigning you, @beepsoft.

@poikilotherm
Copy link
Copy Markdown
Contributor

@pdurbin Jenkins is happy now, the CI env is no longer interfering. Took Ash and myself off. IMHO this is ready for QA unless you see something else.

@pdurbin pdurbin moved this from In Review 🔎 to Ready for QA ⏩ in IQSS Dataverse Project Apr 16, 2026
@cmbz cmbz added the FY26 Sprint 22 FY26 Sprint 22 (2026-04-22 - 2026-05-06) label Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Code Infrastructure formerly "Feature: Code Infrastructure" Component: JSF Involves modifying JSF (Jakarta Server Faces) code, which is being replaced with React. Feature: API Feature: Permissions FY26 Sprint 16 FY26 Sprint 16 (2026-01-28 - 2026-02-11) FY26 Sprint 17 FY26 Sprint 17 (2026-02-11 - 2026-02-25) FY26 Sprint 18 FY26 Sprint 18 (2026-02-25 - 2026-03-11) FY26 Sprint 20 FY26 Sprint 20 (2026-03-26 - 2026-04-08) FY26 Sprint 21 FY26 Sprint 21 (2026-04-08 - 2026-04-22) FY26 Sprint 22 FY26 Sprint 22 (2026-04-22 - 2026-05-06) Size: 3 A percentage of a sprint. 2.1 hours. SPA These changes are required for the Dataverse SPA

Projects

Status: Important
Status: Ready for QA ⏩

Development

Successfully merging this pull request may close these issues.

Extend CORS documentation

9 participants