Skip to content

python_runner.py should check the utf8 length to determine when to use stdin for parameters. #6331

Open
@guzzijones

Description

@guzzijones

SUMMARY

python_runner.py should check the utf8 length to determine when to use stdin for parameters.

Provide a quick summary of your bug report.

        # If parameter size is larger than the maximum allowed by Linux kernel
        # we need to swap to stdin to communicate parameters. This avoids a
        # failure to fork the wrapper process when using large parameters.
        stdin = None
        stdin_params = None
        lenencoded = len(serialized_parameters.encode("utf8"))
        LOG.debug(f"Parameters len encoded: {lenencoded}")
        if len(serialized_parameters) >= MAX_PARAM_LENGTH:
            stdin = subprocess.PIPE
            LOG.debug("Parameters are too big...changing to stdin")
            stdin_params = '{"parameters": %s}\n' % (serialized_parameters)
            args.append("--stdin-parameters")
        else:
            LOG.debug("Parameters are just right...adding them to arguments")
            args.append("--parameters=%s" % (serialized_parameters))

check against MAX_PARAM_LENGTH should use lenencoded . high bit character strings will end up longer than the length of the unicode string.

STACKSTORM VERSION

3.9

OS, environment, install method

all

Steps to reproduce the problem

use a string with high bit characters and a unicode string length > (131072 -15)

Expected Results

action runs without error

Actual Results

[Errno 7] Argument list too long: '/opt/stackstorm/virtualenvs/rt/bin/python'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions