Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TypeError in help command by handling mixed parameter types for sorting #6266

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

shubhamsugara22
Copy link

Summary:

This PR addresses the issue where the st2 run action pack.action -h command fails with a TypeError: '<' not supported between instances of 'str' and 'int'. The error occurs when sorting action parameters that have a mix of names (strings) and positions (integers). In Python 3, comparing these types directly causes a failure.

Root Cause:

The sorting function attempts to sort action parameters by either the position attribute (if present) or the name. In some cases, position is an integer while name is a string, leading to a type comparison error in Python 3.

Fix:

The _get_parameter_sort_value method has been updated to:

  • Convert the position attribute to a string (if it exists) for consistent sorting.
  • Fallback to sorting by the name when position is not available.
  • Ensure Python 3 compatibility by avoiding mixed-type comparisons during parameter sorting.

Fixes #5130

@pull-request-size pull-request-size bot added the size/S PR that changes 10-29 lines. Very easy to review. label Oct 20, 2024
@CLAassistant
Copy link

CLAassistant commented Oct 20, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@pull-request-size pull-request-size bot added size/L PR that changes 100-499 lines. Requires some effort to review. and removed size/S PR that changes 10-29 lines. Very easy to review. labels Oct 20, 2024
@pull-request-size pull-request-size bot added size/S PR that changes 10-29 lines. Very easy to review. and removed size/L PR that changes 100-499 lines. Requires some effort to review. labels Oct 20, 2024
@shubhamsugara22
Copy link
Author

@nzlosh @cognifloyd can you check getting lint error again and again adjusted the file according to black format still
logic is fine but because of lint check is failing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/S PR that changes 10-29 lines. Very easy to review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with action help display when having ordered optional parameters
2 participants