Skip to content
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

Add a log message when a URI template finds no expected variable #54

Open
njharter opened this issue Dec 2, 2022 · 1 comment
Open

Comments

@njharter
Copy link

njharter commented Dec 2, 2022

Problem

When configuring servers, too many times the value {keyId} is used instead of {keyID} (and/or the other way around). This causes either the services to fail or run with a bad URL endpoint.

A Bit of History

Initially keyId use to be present in commit 289f54f, but along with keyID in the same file.
Later keyID in commit 5260d89 is consistently used in both examples.

Comparison Example 1

clortho/resolver.go

Lines 28 to 31 in 289f54f

const (
// KeyIDParameter is the name of the URI template parameter for expanding key URIs.
KeyIDParameterName = "keyId"
)

clortho/resolver.go

Lines 30 to 33 in 5260d89

const (
// KeyIDParameter is the name of the URI template parameter for expanding key URIs.
KeyIDParameterName = "keyID"
)

Comparison Example 2

clortho/resolver.go

Lines 88 to 91 in 289f54f

if err == nil {
location, err = r.keyIDExpander.Expand(map[string]interface{}{
KeyIDParameterName: keyID,
})

clortho/resolver.go

Lines 199 to 202 in 5260d89

func (r *resolver) fetchKey(ctx context.Context, keyID string, request *pendingResolverRequest) (location string, k Key, err error) {
location, err = r.keyIDExpander.Expand(map[string]interface{}{
KeyIDParameterName: keyID,
})

Suggested Solution

Make this keyID value case insensitive.

@johnabass
Copy link
Collaborator

URI templates are governed by https://www.rfc-editor.org/rfc/rfc6570. Specifically, from section 2.3:

Variable names are case-sensitive because the name might be expanded within a case-sensitive URI component.

clortho consistently uses keyID to conform to golang naming conventions.

We could put a log message or something when no key id parameter is found.

@johnabass johnabass changed the title keyId vs keyID Add a log message when a URI template finds no expected variable Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants