<html>
    <head>
      <base href="https://bugzilla.netfilter.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - python3-nftables wrong return code when working with JSON"
   href="https://bugzilla.netfilter.org/show_bug.cgi?id=1499">1499</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>python3-nftables wrong return code when working with JSON
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>nftables
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86_64
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Debian GNU/Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P5
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>nft
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>pablo@netfilter.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>arturo@netfilter.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Original bug report in the Debian bug tracker:
<a href="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=981857">https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=981857</a>



I am using the python wrapper in a program and faced a problem.
Trying to list a Table while the Ruleset is empty returns an error, no problem
yet.
Every subsequent call to json_cmd() on the same nftables.Nftables class
instance returns -1 in return code.

Here is a short script reproducing the error :

###### testNFTABLES.py ++

import nftables
import json

nft = nftables.Nftables()
nft.set_json_output(True)

flushRulesetCMD = '{ "nftables": [ { "flush": { "ruleset": null }} ]}'
getTableCMD = '{ "nftables": [ { "list": { "table": { "family": "inet", "name":
"FooTable" }}} ]}'
addTableCMD = '{ "nftables": [ { "add": { "table": { "family": "inet", "name":
"FooTable" }}} ]}'

result = nft.json_cmd(json.loads(flushRulesetCMD))
print(result)

result = nft.json_cmd(json.loads(getTableCMD))
print(result)

# Resetting Nftables class instance makes it work
# nft = nftables.Nftables()

result = nft.json_cmd(json.loads(addTableCMD))
print(result)

###### testNFTABLES.py --</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are watching all bug changes.</li>
      </ul>
    </body>
</html>