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.

Modular Input: Error during ValidationDefinition/InputDefinition when no value for parameter is passed

See original GitHub issue

I am able to reproduce this using v1.9.1. This issue happens when the user provides no value for a modular input parameter. https://github.com/splunk/splunk-sdk-java/blob/master/splunk/src/main/java/com/splunk/modularinput/XmlUtil.java textInNode() line number 38:

static String textInNode(Node node, String errorMessage) throws MalformedDataException {
        Node child = node.getFirstChild();
        if (child.getNodeType() != Node.TEXT_NODE) {
            throw new MalformedDataException(errorMessage);
        } else {
            return ((Text)child).getData();
        }
    }

Here, no null check is performed for the child variable. In case when the modular input parameter has no value, child will be null and child.getNodeType() leads to null pointer.

Sample input to --validate-arguments that triggers the error:

<?xml version="1.0" encoding="utf-16"?>
<items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <server_host>tiny</server_host>
    <server_uri>https://127.0.0.1:8089</server_uri>
    <checkpoint_dir>/opt/splunk/var/lib/splunk/modinputs</checkpoint_dir>
    <session_key>123102983109283019283</session_key>
    <!-- The items element only ever contains one item element -->
    <item name="aaa">
        <param name="param1">value1</param>
        <param name="param_bug"></param>
        <param name="disabled">0</param>
        <param name="index">default</param>
        <param_list name="multiValue">
            <value>value1</value>
            <value>value2</value>
        </param_list>
        <param_list name="multiValue2">
            <value>value3</value>
            <value>value4</value>
        </param_list>
    </item>
</items>

In the above example param_bug has no value (user did not input any value to the modular input parameter), this causes child to be null in the textInNode() method.

Please let me know if you need any other information regarding this issue.

Similar issue was created previously: https://github.com/splunk/splunk-sdk-java/issues/122 back in March 2018, but it was closed stating that it could not reproduced.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ashah-splunkcommented, Oct 27, 2022

@jrobins04 thanks for the detailed steps to reproduce the issue. We are looking into this and update you soon.

0reactions
jrobins04commented, Dec 14, 2022

@ashah-splunk Thank you for quickly fixing this. I have verified that the bug has been fixed in the latest release. Thanks again !

Read more comments on GitHub >

github_iconTop Results From Across the Web

splunklib.modularinput — Splunk SDK for Python API Reference
When Splunk calls a modular input script in validation mode, it will pass in an XML document giving information about the Splunk instance...
Read more >
Configure runbook input parameters in Azure Automation
This article tells how to configure runbook input parameters, which allow data to be passed to a runbook when it's started.
Read more >
Validating Parameters with PowerShell ValidateScript ...
Learn about one of the best ways to parameter input with the PowerShell ValidateScript validation attribute in this walkthrough!
Read more >
MATLAB addParameter - MathWorks
This MATLAB function adds the parameter name of an optional name-value pair argument into the input parser scheme.
Read more >
Advanced validation • shinyvalidate
If child_iv$is_valid() returns FALSE , then parent_iv$is_valid() will also return FALSE —in other words, an input validator is only valid if all of...
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