Skip to content

Failing to parse BGP path that uses confederations #339

@internetplumber

Description

@internetplumber

Deployment Type

Docker

Version

v2.0.4

Steps to Reproduce

Firstly, apologies if this shouldn't be an 'issue' and I've missed a better place to discuss this. Our BGP setup (using Junos OS) uses BGP confederations (yes, I know it's outdated, but that's the way it is). If I look up a route on the router directly, it comes back with this:

    A.B.0.0/18      *[BGP/170] 4w5d 07:41:53, MED 300, localpref 100
                          AS path: (65527) nnnnn ?, validation-state: unverified
                        >  to m.n.o.p via ae30.0

However, hyperglass is barfing on that with:

    2025-09-10 15:29:50.656 | CRITICAL | hyperglass.plugins._builtin.bgp_route_juniper:parse_juniper:114 - 2 validation errors for JuniperBGPTable
    rt.0.rt_entry.0.as_path
      Value error, invalid literal for int() with base 10: '(65527)' [type=value_error, input_value='(65527) nnnnn ?', input_type=str]
        For further information visit https://errors.pydantic.dev/2.11/v/value_error
    rt.0.rt_entry.1.as_path
      Value error, invalid literal for int() with base 10: '(65527)' [type=value_error, input_value='(65527) nnnnn ?', input_type=str]
        For further information visit https://errors.pydantic.dev/2.11/v/value_error

Which, to my uneducated eye suggest it is failing to cast the string "(65527)" to an int. I've tried stripping out braces in hyperglass/models/parsing/juniper.py validate_as_path(), but I guess that's only for looking up paths.

parse_juniper() in bgp_route_juniper() is beyond my elementary python from a quick look, but I suspect somewhere in there we need to strip out parentheses in the AS path.

Expected Behavior

The queried route to appear in the UI.

Observed Behavior

An error is shown in the UI:

Image

Configuration

org_name: MyOrg
site_title: "MyOrg Looking Glass"
site_description: "MyOrg Looking Glass"
request_timeout: 300
logging:
  directory: /var/log/hyperglass/
messages:
    general: The test did not complete successfully
    request_timeout: The test did not complete successfully.

Devices

routers:
  - name: myrouter.net
    address: w.x.y.z
    group: GROUPNAME
    credential:
      username: username
      key: /path/lg_rsa
    display_name: myrouter.net
    port: 22
    platform: junos
    attrs:
      source4: e.f.g.h
      source6: "JJ:KK:LL::NN"

Logs

2025-09-10 15:29:49.180 | DEBUG    | hyperglass.models.directive:membership:111 - Checking target membership
2025-09-10 15:29:49.180 | DEBUG    | hyperglass.models.directive:membership:116 - Target membership verified
2025-09-10 15:29:49.180 | DEBUG    | hyperglass.models.directive:in_range:123 - Target is in range
2025-09-10 15:29:49.181 | DEBUG    | hyperglass.models.api.query:validate_query_target:107 - Validation passed
2025-09-10 15:29:49.181 | INFO     | hyperglass.api.routes:query:79 - Starting query execution
2025-09-10 15:29:49.182 | DEBUG    | hyperglass.api.routes:query:97 - Cache miss
2025-09-10 15:29:49.189 | DEBUG    | hyperglass.execution.main:execute:51 - 
2025-09-10 15:29:49.243 | DEBUG    | hyperglass.execution.drivers._construct:__init__:46 - Constructing query
2025-09-10 15:29:49.247 | DEBUG    | hyperglass.execution.drivers._construct:queries:129 - Constructed query
2025-09-10 15:29:49.255 | DEBUG    | hyperglass.execution.drivers.ssh_netmiko:collect:51 - Connecting to device
INFO - 2025-09-10 15:29:49,300 - paramiko.transport - transport - Connected (version 2.0, client OpenSSH_7.5)
INFO - 2025-09-10 15:29:49,634 - paramiko.transport - transport - Authentication (publickey) successful!
2025-09-10 15:29:50.643 | DEBUG    | hyperglass.plugins._manager:execute:186 - Output Plugin Starting Value
2025-09-10 15:29:50.656 | CRITICAL | hyperglass.plugins._builtin.bgp_route_juniper:parse_juniper:114 - 2 validation errors for JuniperBGPTable
rt.0.rt_entry.0.as_path
  Value error, invalid literal for int() with base 10: '(65527)' [type=value_error, input_value='(65527) nnnnn ?', input_type=str]
    For further information visit https://errors.pydantic.dev/2.11/v/value_error
rt.0.rt_entry.1.as_path
  Value error, invalid literal for int() with base 10: '(65527)' [type=value_error, input_value='(65527) nnnnn ?', input_type=str]
    For further information visit https://errors.pydantic.dev/2.11/v/value_error
2025-09-10 15:29:50.656 | ERROR    | hyperglass.exceptions._common:__init__:32 - rt, 0, rt_entry, 0, as_path, rt, 0, rt_entry, 1, as_path
2025-09-10 15:29:50.656 | CRITICAL | hyperglass.api.error_handlers:app_handler:66 - hyperglass Error
2025-09-10 15:29:50.657 | INFO     | logging:callHandlers:1762 - 172.18.0.1:60328 - "POST /api/query HTTP/1.0" 400

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions