Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds URL-to-resource decoding via a new public Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
ktor-shared/ktor-resources/common/test/io/ktor/tests/resources/UrlDeserializationTest.kt (1)
20-21: Rename the new tests to the repo's backtick style.The new test cases still use identifier-style function names. Please switch them to descriptive backtick names so the file matches the rest of the test convention.
As per coding guidelines, "
**/test/**/*.kt: Use descriptive test names in backticks following the pattern:describe what is being tested."Also applies to: 35-36, 57-58, 98-99, 126-127, 134-135, 147-148
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ktor-shared/ktor-resources/common/test/io/ktor/tests/resources/UrlDeserializationTest.kt` around lines 20 - 21, Rename the identifier-style test functions in UrlDeserializationTest.kt (e.g., fun testSimplePath(), and the other test functions listed around the commented ranges) to descriptive backtick-style names following the repo pattern (e.g., fun `describe what is being tested`()) — update each function declaration (for the functions at the marked ranges) to use a quoted backtick name that describes the behavior under test instead of the camelCase identifier.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@ktor-shared/ktor-resources/common/src/io/ktor/resources/serialization/ResourcesFormat.kt`:
- Around line 125-167: decodeFromUrl() currently walks resource path parts in
reverse and doesn’t validate literal segments against url.segments, and its
reverse-counting (uses resourcesStart/consumedSegments and
endsWithOptionalParameterName/endsWithTrailingParameterName) mis-aligns parent
placeholders when optional ({name?}) is omitted or tail ({name...}) expands; to
fix, rework the loop in ResourcesFormat.decodeFromUrl to parse
encodeToPathPattern(deserializer) left-to-right (same approach as
UrlBuilder.href()), validating each literal segment against segments at the
current read index, consuming exactly one segment for literals and
single-parameter parts, zero-or-one for optional ({name?}) only when present,
and N segments for trailing ({name...}), updating the read index accordingly and
populating parametersBuilder; remove reliance on reverse resourcesStart
arithmetic and ensure parents are traversed in order (use
current.elementDescriptors -> membersWithAnnotations) so offsets remain correct.
- Around line 114-172: New public API method decodeFromUrl has been added to
ResourcesFormat but the module ABI signature files were not updated; regenerate
the ABI files by running the Gradle task that refreshes legacy ABI signatures
(./gradlew :ktor-shared:ktor-resources:updateLegacyAbi), verify that the
generated ktor-resources.api and ktor-resources.klib.api include the new
decodeFromUrl entry, and commit the updated files to the repo before merging.
In
`@ktor-shared/ktor-resources/common/test/io/ktor/tests/resources/PathPatternSerializationTest.kt`:
- Around line 37-48: The nested resource inner classes reference the wrong
parent type so encodeToPathPattern() no longer traverses the parent variants;
update the inner data class constructors so ChildClassWithSlash and
ChildClassWithoutSlash inside NestedClassWithSlash use parent:
NestedClassWithSlash, and the ChildClassWithSlash inside NestedClassWithoutSlash
uses parent: NestedClassWithoutSlash (i.e., restore the parent parameter types
to the enclosing NestedClass variant) so the parent trailing-slash cases are
exercised again.
In
`@ktor-shared/ktor-resources/common/test/io/ktor/tests/resources/UrlDeserializationTest.kt`:
- Line 10: Remove the inaccessible import of
io.ktor.tests.resources.ParametersSerializationTest.V1 at the top of the file;
it conflicts with and is unnecessary because this test file defines its own V1
(see the V1 declaration around line 112). Delete the import statement
referencing ParametersSerializationTest.V1 so the local V1 is used and the
private symbol is not referenced.
---
Nitpick comments:
In
`@ktor-shared/ktor-resources/common/test/io/ktor/tests/resources/UrlDeserializationTest.kt`:
- Around line 20-21: Rename the identifier-style test functions in
UrlDeserializationTest.kt (e.g., fun testSimplePath(), and the other test
functions listed around the commented ranges) to descriptive backtick-style
names following the repo pattern (e.g., fun `describe what is being tested`()) —
update each function declaration (for the functions at the marked ranges) to use
a quoted backtick name that describes the behavior under test instead of the
camelCase identifier.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8df9aff5-f851-493e-8450-c9d4c8e2c1d2
📒 Files selected for processing (5)
ktor-shared/ktor-resources/common/src/io/ktor/resources/serialization/Decoders.ktktor-shared/ktor-resources/common/src/io/ktor/resources/serialization/ResourcesFormat.ktktor-shared/ktor-resources/common/test/io/ktor/tests/resources/ParametersSerializationTest.ktktor-shared/ktor-resources/common/test/io/ktor/tests/resources/PathPatternSerializationTest.ktktor-shared/ktor-resources/common/test/io/ktor/tests/resources/UrlDeserializationTest.kt
Subsystem
Resources
Motivation
https://youtrack.jetbrains.com/issue/KTOR-9295/ResourceFormat-Support-decoding-resources-from-a-path
Solution
Implemented...