question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSONXSL plugin error

See original GitHub issue

Hi,

I am getting below error when trying convert YANG models to XSL schema.

Pyang version: 2.3.2

Command: pyang --lax-quote-checks -f jsonxsl files/*.yang -o yang.xsl

Error

Traceback (most recent call last):
  File "/usr/local/bin/pyang", line 533, in <module>
    run()
  File "/usr/local/bin/pyang", line 502, in run
    emit_obj.emit(ctx, modules, fd)
  File "/usr/local/lib/python3.6/site-packages/pyang/plugins/jsonxsl.py", line 93, in emit
    self.process_module(module)
  File "/usr/local/lib/python3.6/site-packages/pyang/plugins/jsonxsl.py", line 113, in process_module
    self.process_children(yam, "//nc:*", 1)
  File "/usr/local/lib/python3.6/site-packages/pyang/plugins/jsonxsl.py", line 170, in process_children
    self.process_children(ch, p, level + offset)
  File "/usr/local/lib/python3.6/site-packages/pyang/plugins/jsonxsl.py", line 170, in process_children
    self.process_children(ch, p, level + offset)
  File "/usr/local/lib/python3.6/site-packages/pyang/plugins/jsonxsl.py", line 170, in process_children
    self.process_children(ch, p, level + offset)
  [Previous line repeated 1 more time]
  File "/usr/local/lib/python3.6/site-packages/pyang/plugins/jsonxsl.py", line 167, in process_children
    self.type_param(ch, ct)
  File "/usr/local/lib/python3.6/site-packages/pyang/plugins/jsonxsl.py", line 175, in type_param
    types = self.get_types(node)
  File "/usr/local/lib/python3.6/site-packages/pyang/plugins/jsonxsl.py", line 219, in get_types
    resolve(node.i_leafref_ptr[0].search_one("type"))
TypeError: 'NoneType' object is not subscriptable	

I was also able to overcome the above error by adding simple check like below in jsonxsl.py function get_types

# if typ.arg == "leafref":
if typ.arg == "leafref" and node.i_leafref_ptr is not None:
    resolve(node.i_leafref_ptr[0].search_one("type"))
else:
    resolve(typ)

I am not sure if its a bug or intended functionality but with above changes XSL schema gets generated followed by JSON file.

Can anyone please confirm what should be done for this issue?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
fredgancommented, Aug 21, 2020

@rawat-he Hi, I do the modifications as follows,

  • Remove two unused import modules.
  • Add leaf action-id in list progress-report
module sample {
  yang-version 1.1;
  namespace my:sample;
  prefix mysample;

  import ietf-inet-types { prefix inet; }

  typedef on-off {
    type enumeration {
      enum on {  value 1; }
      enum off { value 0; }
    }
    description "";
  }
   container test {
		list backup {
			key id;
			description "";

			leaf id {
				type string;
				description "";
			}
			leaf auto-export {
				type on-off ;
				default off ;
				description "";
			}
			leaf auto-export-uri {
				type inet:uri;
				must '../auto-export = "false" or .' ;
				description "";
			}
			list progress-report {
				key action-id;
				config false;
				max-elements 1;
				description "";
				leaf action-id {
				    type string;
				}
			}
			action create-backup {
				description "";
				input {
					leaf name {
                        type string;
                        description "";
					}
				}
				output {
					leaf return-value {
                        type leafref {
                            path "../../progress-report/action-id" ;
                        }
                        mandatory true;
                        description "";
					}
				}
			}
		}
   }
}
0reactions
rawat-hecommented, Aug 23, 2020

Closing the issue and thank you @fredgan for your prompt responses.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSONXSL plugin needs a valid module · Issue #336 - GitHub
Hi, Am trying to get json from openconfig-bgp and seeing "JSONXSL plugin needs a valid module" error with "-f jsonxsl" argument.
Read more >
How to use the pyang.plugin.PyangPlugin function in ... - Snyk
To help you get started, we've selected a few pyang.plugin. ... import json from pyang import plugin, error from pyang.util import unique_prefixes def ......
Read more >
pyang.error.err_level Example - Program Talk
Learn how to use python api pyang.error.err_level. ... EmitError("JSONXSL plugin needs a valid module") self.real_prefix = unique_prefixes(ctx) ...
Read more >
Convert Yang models to JSON - ConfD User Community
If I try the same command for other yang models that import tailf-common, I get an error, stating that 'JSONXSL plugin needs a...
Read more >
How to Fix the Invalid JSON Error in WordPress? - Rank Math
Check the URL Settings of the WordPress Site · Fix the WordPress Permalink Structure · Regenerate WordPress .htaccess File · Check the Themes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found