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

Invalid error message parsing subject maps #4096

Closed
2 tasks done
ColinSullivan1 opened this issue Apr 24, 2023 · 1 comment
Closed
2 tasks done

Invalid error message parsing subject maps #4096

ColinSullivan1 opened this issue Apr 24, 2023 · 1 comment
Assignees
Labels
defect Suspected defect such as a bug or regression

Comments

@ColinSullivan1
Copy link
Member

Defect

This is minor, but could save certain users some time.

The NATS server is erroneously reporting an interface conversion error when processing configuration files and detecting errors with subject maps (in this case more than 100% allocation with weighted mapping). This is especially confusing when the server is parsing JSON configuration files, as these types of errors can be reported from invalid json.

  • Included nats-server -DV output
nats-server: sample.json:6:53: interface conversion: interface {} is []interface {}, not string
 $ cat sample.json 
accounts {
  testacct {
    "mappings": {
       "s1": [
          { "destination": "d1.1", "weight": "50%" },
          { "destination": "d1.2", "weight": "51%" } 
       ] 
    }
  }
}

$ nats-server -config sample.json

Versions of nats-server and affected client libraries used:

nats-server: v2.9.17-beta.1

OS/Container environment: N/A

Steps or code to reproduce the issue:

Run the server with the configuration provided above.

Expected result:

An error message indicating the total weight needs to be <= 100

Actual result:

interface conversion: interface {} is []interface {}, not string

Suggestions

I'll see if I can get a test setup later with a PR but in case someone beats me to it, the fix would appear to be replacing string with []interface{}
here:

err := &configErr{tk, fmt.Sprintf("Error adding mapping for %q to %q : %v", subj, v.(string), err)}
and with and {}interface here:
err := &configErr{tk, fmt.Sprintf("Error adding mapping for %q to %q : %v", subj, v.(string), err)}

@bruth bruth added defect Suspected defect such as a bug or regression and removed 🐞 bug labels Aug 18, 2023
@jnmoyne
Copy link
Contributor

jnmoyne commented Sep 25, 2023

This has now been fixed a while ago by #4202

Currently the mapping example above returns the following error:
Error adding mapping for "s1" : total weight needs to be <= 100

@jnmoyne jnmoyne closed this as completed Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Suspected defect such as a bug or regression
Projects
None yet
Development

No branches or pull requests

5 participants