ls1intum / Artemis

Artemis - Interactive Learning with Automated Feedback
https://docs.artemis.cit.tum.de
MIT License
452 stars 275 forks source link

`File upload exercises`: Fix an issue when downloading submission files #8882

Closed Strohgelaender closed 3 days ago

Strohgelaender commented 4 days ago

Checklist

General

Server

Motivation and Context

There is an internal server error when downloading submission files of non-standard data types. Fixes #8870

Description

The fallback solution for determining the media type uses the activation API. Here the necessary dependency got lost, probally during the Spring Boot 3 upgrade due to the package rename

Steps for Testing

Prerequisites:

  1. Submit something as a student
  2. As a tutor, download the submitted file
  3. See that the download works.

Testserver States

[!NOTE] These badges show the state of the test servers. Green = Currently available, Red = Currently locked Click on the badges to get to the test servers.

Review Progress

Code Review

Test Coverage

Summary by CodeRabbit

coderabbitai[bot] commented 4 days ago

Walkthrough

The recent updates involve adding a dependency on "com.sun.activation:jakarta.activation:2.0.1" to the build.gradle file to address security concerns and improve functionality. Additionally, new test methods and modifications were made to the FileUploadSubmissionIntegrationTest class, enhancing its ability to test file submissions with different file paths and media types, thus improving the handling and assessment of diverse file formats, including .ipynb.

Changes

File Path Change Summary
build.gradle Added a new dependency ("com.sun.activation:jakarta.activation:2.0.1"). Updated guava and gson dependencies.
src/test/java/.../FileUploadSubmissionIntegrationTest.java Modified initTestCase, added submitFileSpecialExtensions, and enhanced submitFile method for varied testing.

Assessment against linked issues

Objective Addressed Explanation
Ensure the system supports the download and opening of .ipynb files during assessment (#8870).

Recent review details **Configuration used: .coderabbit.yaml** **Review profile: ASSERTIVE**
Commits Files that changed from the base of the PR and between 1edba55278ab9cbfb41530f937874581b48bd0b7 and 45010943b79380929a8fb0316ec4710a4105547e.
Files selected for processing (2) * build.gradle (1 hunks) * src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java (3 hunks)
Additional context used
Path-based instructions (1)
src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java (1) Pattern `src/test/java/**/*.java`: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true
Additional comments not posted (5)
build.gradle (2)
`440-440`: **Dependency Addition Approved** The addition of `com.sun.activation:jakarta.activation:2.0.1` is appropriate for handling media type determination issues mentioned in the PR. It's correctly placed in the dependency block, ensuring that it is part of the build. --- `440-440`: **Dependency Update Approved** The update to `com.google.code.gson:gson:2.11.0` is part of the security improvements. It's important to ensure that this update does not introduce any breaking changes or compatibility issues with the existing codebase.
src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java (3)
`156-162`: **Approval for adding `submitFileSpecialExtensions` test method.** This method is crucial for testing the submission of `.ipynb` files, aligning with the PR's objective to fix issues related to non-standard file types. The implementation seems correct and directly addresses the problem described in the linked issue. --- `165-168`: **Approval for the overloaded `submitFile` method signature.** The addition of the `MediaType` parameter allows testing different media types, enhancing the flexibility and coverage of file upload tests. This change is well-aligned with the PR's goal to support different file types effectively. --- `97-97`: **Verify removal of `throws Exception` in `initTestCase` method.** The removal of the `throws Exception` clause suggests a change in error handling within the method. Please ensure that all exceptions are properly handled or that none are thrown.
Verification successful --- **Verified removal of `throws Exception` in `initTestCase` method.** The `initTestCase` method in `FileUploadSubmissionIntegrationTest.java` does not throw any checked exceptions, confirming the correctness of removing the `throws Exception` clause. - `FileUploadSubmissionIntegrationTest.java`, line 97
Scripts executed The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify that no checked exceptions are thrown within the `initTestCase` method. ast-grep --lang java --pattern $'void initTestCase() { $$$ }' ``` Length of output: 190 --- --- Script: ```shell #!/bin/bash # Description: Verify that no checked exceptions are thrown within the `initTestCase` method, excluding problematic files. ast-grep --lang java --pattern $'void initTestCase() { $$$ }' --exclude src/test/resources/test-data/repository-export/EncodingISO_8559_1.java ``` Length of output: 348 --- --- Script: ```shell #!/bin/bash # Description: Verify that no checked exceptions are thrown within the `initTestCase` method, excluding problematic files using find. find . -type f -name "*.java" ! -path "./src/test/resources/test-data/repository-export/EncodingISO_8559_1.java" -print0 | xargs -0 ast-grep --lang java --pattern $'void initTestCase() { $$$ }' ``` Length of output: 196 --- --- Script: ```shell #!/bin/bash # Description: Search for the `initTestCase` method definition using rg. rg 'void initTestCase\(' ``` Length of output: 12236 --- --- Script: ```shell #!/bin/bash # Description: Extract the implementation of the `initTestCase` method from `FileUploadSubmissionIntegrationTest.java`. ast-grep --lang java --pattern $'void initTestCase() { $$$ }' src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java ``` Length of output: 162 --- --- Script: ```shell #!/bin/bash # Description: Extract the implementation of the `initTestCase` method from `FileUploadSubmissionIntegrationTest.java` using rg. rg -A 20 -B 5 'void initTestCase\(' src/test/java/de/tum/in/www1/artemis/exercise/fileupload/FileUploadSubmissionIntegrationTest.java ``` Length of output: 1759
--- Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.