Skip to content

Tolerate repeated and trailing slashes when routing request paths #118

Backlog

Description

@manlikeHB

Summary

The request router exact-matches the path after stripping the /vss prefix, so any request carrying a redundant slash falls through to 400 Invalid request path. This is easy to hit by accident, because clients build the endpoint URL by appending to a user-supplied base URL.

Reproduction

A base URL of https://host/vss/ (trailing slash) produces https://host/vss//getObject. The server then sees:

path = "/vss//getObject"
strip_prefix("/vss") -> "//getObject"
match                 -> falls through to `_` -> 400 "Invalid request path."

Why this is worth fixing

The failure is silent in a specific way. ldk-node surfaces it as "can't read from store", which is the identical error returned when the VSS database is empty or the server is otherwise misconfigured. That ambiguity is why lightningdevkit/ldk-node#672 took as long to diagnose as it
did.

Proposed change

Normalize the path once, before the prefix strip and the match: collapse runs of / into one and drop a trailing /.

That normalization cannot change meaning in this API: four fixed endpoints, no path parameters, no resource hierarchy, so /vss//getObject cannot denote anything other than /vss/getObject.

This is the tolerance half. The client emits the bad path in the first place and will be fixed separately, that half makes requests correct against any VSS implementation, this half makes clients already deployed against an older vss-client-ng work again. Both are wanted, and per the note in vss-client-ng's 0.6.0 changelog a server release should land ahead of the matching client release.

Background: lightningdevkit/ldk-node#672. lightningdevkit/ldk-node#1264 was an earlier attempt I opened in the wrong repository; tnull redirected it here.

I'll send a PR along these lines, happy to adjust if different semantics are preferred.

cc @tankyleo

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions