-
Notifications
You must be signed in to change notification settings - Fork 307
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
Development
: Migrate file URL paths for various entities
#10433
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitsIntegrationTest.java (1)
296-298
: Consider using consistent variable naming pattern.While the functionality is correct, there's an inconsistency in variable naming between the first attachment unit (using
requestUrl
) and the second attachment unit (usingattachmentRequestUrl
). Consider standardizing the variable naming for better readability and maintainability.-String attachmentPathSecondUnit = attachmentUnitList.get(1).getAttachment().getLink(); -String attachmentRequestUrl = String.format("%s%s", ARTEMIS_FILE_PATH_PREFIX, attachmentPathSecondUnit); -byte[] fileBytesSecond = request.get(attachmentRequestUrl, HttpStatus.OK, byte[].class); +String requestUrl = String.format("%s%s", ARTEMIS_FILE_PATH_PREFIX, attachmentUnitList.get(1).getAttachment().getLink()); +byte[] fileBytesSecond = request.get(requestUrl, HttpStatus.OK, byte[].class);
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/test/java/de/tum/cit/aet/artemis/exam/ExamUserIntegrationTest.java
(4 hunks)src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadSubmissionIntegrationTest.java
(5 hunks)src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentResourceIntegrationTest.java
(3 hunks)src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitsIntegrationTest.java
(3 hunks)src/test/java/de/tum/cit/aet/artemis/quiz/QuizExerciseIntegrationTest.java
(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- src/test/java/de/tum/cit/aet/artemis/exam/ExamUserIntegrationTest.java
- src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentResourceIntegrationTest.java
- src/test/java/de/tum/cit/aet/artemis/quiz/QuizExerciseIntegrationTest.java
🧰 Additional context used
📓 Path-based instructions (1)
`src/test/java/**/*.java`: test_naming: descriptive; test_si...
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
src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitsIntegrationTest.java
src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadSubmissionIntegrationTest.java
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: server-style
- GitHub Check: server-tests
- GitHub Check: Analyse
🔇 Additional comments (9)
src/test/java/de/tum/cit/aet/artemis/fileupload/FileUploadSubmissionIntegrationTest.java (6)
3-3
: Good addition of the constant import.The addition of this import is aligned with the PR objective of migrating file URL paths. This constant will be used for constructing proper request URLs.
144-144
: File path format correctly updated.The file path has been correctly updated to no longer include the API endpoint prefix ("/api/core/files/"). This change is consistent with the migration described in the PR objective where file paths are now stored without the prefix.
172-173
: URL construction pattern properly implemented.The new code correctly uses the
ARTEMIS_FILE_PATH_PREFIX
constant to construct the full request URL at runtime, which is a more maintainable approach. This separates the storage format from the API endpoint format, making the system more flexible.
696-696
: Consistent file path update in test case.The file path format has been correctly updated in the test case, removing the API endpoint prefix ("/api/core/files/"). This ensures consistency with the new approach to file path handling.
705-705
: Consistent file path update in test case.The file path format has been correctly updated in the test case, removing the API endpoint prefix ("/api/core/files/"). This ensures consistency with the new approach to file path handling.
1-710
:✅ Verification successful
Verify all instances of file path updates.
The code changes look good and follow a consistent pattern of removing the API endpoint prefix from stored file paths and adding it at request time. However, it's important to verify that all instances where file paths are constructed follow this pattern across the entire PR.
🏁 Script executed:
#!/bin/bash # Description: Search for any remaining instances of hardcoded "/api/core/files/" in file paths # Search for hardcoded API path prefixes in Java files echo "Searching for potential missed file path prefixes:" rg -i "/api/core/files/" --type javaLength of output: 2281
Verified: File Path Updates Are Consistent
After running the search, the only occurrences of the hardcoded
"/api/core/files/"
string appear in the constant definition and in tests that explicitly reference the API endpoint. In the main code (especially in file upload-related logic), file paths are built without the prefix and are correctly prefixed at request time using the constant (ARTEMIS_FILE_PATH_PREFIX
). This indicates that the changes follow the intended pattern across the PR.
- File paths in production (e.g., in the file upload submission integration tests) correctly remove the prefix when stored and add it upon constructing the request URL.
- Remaining hardcoded occurrences in tests and in
Constants.java
are expected and appropriate.src/test/java/de/tum/cit/aet/artemis/lecture/AttachmentUnitsIntegrationTest.java (3)
3-3
: Proper import of file path constant.The import of the
ARTEMIS_FILE_PATH_PREFIX
constant from Constants.java is correctly added, ensuring consistency with the API path migration described in the PR objectives.
287-288
: Correct URL path construction for first attachment unit.The URL path is now properly constructed using the
ARTEMIS_FILE_PATH_PREFIX
constant, aligning with the migration of API paths mentioned in the PR objectives. This change ensures that previously existing assets can be loaded correctly after the upgrade.
285-303
:❓ Verification inconclusive
Verify attachment file loading works across all affected modules.
The test confirms that files can be loaded with the new URL path structure, but it might be worth ensuring that this works consistently across all modules that use file attachments. Consider adding verification for edge cases like file names with special characters.
🏁 Script executed:
#!/bin/bash # Description: Check all file path references in the codebase to ensure consistent use of ARTEMIS_FILE_PATH_PREFIX # Look for direct file path references that might need the prefix echo "Finding direct file path patterns that might need updating:" rg -l "getAttachment\(\).getLink\(\)" --type java | grep -v "AttachmentUnitsIntegrationTest.java" # Check for uses of attachment links without the ARTEMIS_FILE_PATH_PREFIX echo "Finding potential file path references without the prefix:" rg -l "getAttachment\(\).getLink\(\)" --type java | xargs rg -l "request.get\(" | grep -v "AttachmentUnitsIntegrationTest.java" | xargs rg -A 3 "request.get\(.*getAttachment\(\).getLink\(\)" # Check if prefix is correctly defined echo "Verifying ARTEMIS_FILE_PATH_PREFIX definition:" rg "ARTEMIS_FILE_PATH_PREFIX.*=" --type javaLength of output: 1364
Action Required: Ensure Consistent Attachment Loading Across Modules and Test Edge Cases
- The ARTEMIS_FILE_PATH_PREFIX is correctly defined in
src/main/java/de/tum/cit/aet/artemis/core/config/Constants.java
and is used across multiple modules (e.g., FileResource, PyrisWebhookService, SlideSplitterService, LectureUnitService, AttachmentUnitService).- The AttachmentUnitsIntegrationTest properly verifies file loading with the new URL structure by checking PDF page counts.
- Please review the attachment handling in the referenced modules to confirm that the new path construction works as expected in all cases.
- Consider adding tests—especially for file names with special characters—to ensure that edge cases are handled consistently.
src/main/resources/config/liquibase/changelog/20250302174100_changelog.xml
Outdated
Show resolved
Hide resolved
src/main/resources/config/liquibase/changelog/20250302174100_changelog.xml
Outdated
Show resolved
Hide resolved
17d0b15
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code reapprove
server test coverage thresholds are broken on develop, these changes have no influence on the (exam-)coverage |
Do not deploy to test servers because of DB migrations
Checklist
General
Server
Motivation and Context
In #10416, we changed the URL paths to be prefixed by the respective module name.
Since we've adapted the asset paths (that are stored in the DB), existing assets can currently not be loaded after upgrading.
Also, we will remove the API base prefix for files (
/api/core/files
) from the paths stored literally in the database. Instead, the client has to append the prefix.Description
Liquibase Migration that updates the paths for all entities that rely on this URL path. Additionally, includes all paths that need to be adapted.
Steps for Testing
Note
: Needs to be tested locally.https://artemis-test.../api/core/files/testfile.png
. the file doesn't have to exist/api/core/file
-endpoint works fine.Testserver States
You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.
Review Progress
Code Review
Manual Tests
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Style