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

Added include_attributes and exclude_attributes to GET /api/v1/executions/{id} #4497

Merged
merged 9 commits into from
Mar 19, 2019

Conversation

nmaludy
Copy link
Member

@nmaludy nmaludy commented Jan 15, 2019

Previously GET /api/v1/executions/{id} did not have the include_attributes or exclude_attributes query parameters, meaning it couldn't filter the output of large executions. This PR adds that ability.

@Kami are any other modifications necessary?

TODO

  • Tests

@nmaludy
Copy link
Member Author

nmaludy commented Jan 15, 2019

FYI just found a bug in router.py was throwing an exception:

2019-01-14 22:03:51,896 140229294134928 ERROR error_handling [-] API call failed: local variable 'item' referenced before assignment
Traceback (most recent call last):
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/middleware/error_handling.py", line 47, in __call__
    return self.app(environ, start_response)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/middleware/streaming.py", line 48, in __call__
    return self.app(environ, start_response)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/router.py", line 600, in as_wsgi
    resp = self(req)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/router.py", line 554, in __call__
    exclude_attributes=exclude_attributes)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/router.py", line 677, in _process_response
    result = process_item(item)
UnboundLocalError: local variable 'item' referenced before assignment (_exception_data={},_exception_class='UnboundLocalError',_exception_message="local variable 'item' referenced before assignment")

Looks like that was a copy/paste error and should have been result = process_item(data) instead.

@@ -669,7 +669,7 @@ def process_item(item):
result.append(item)
elif isinstance(data, dict):
# get_one response
result = process_item(item)
result = process_item(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. It looks we don't have test case for this scenario? :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides that and test case for handling of those attributes it looks good to me 👍

I believe we already have a pattern for include and exclude attributes test cases. We might not just have one for "get one" API endpoints yet.

@Kami
Copy link
Member

Kami commented Jan 15, 2019

Thanks for opening this.

Can you please also add a changelog entry?

@Kami Kami added this to the 3.0.0 milestone Jan 15, 2019
@Kami Kami added the API label Jan 15, 2019
@nmaludy
Copy link
Member Author

nmaludy commented Jan 18, 2019

Please don't merge this yet

I found a least one bug in st2client where it's using ?include_attributes already, but doesn't ask for all of the attributes that it needs.

So far i've found the following is broken:

  • st2 execution get xxx
Traceback (most recent call last):
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2client/shell.py", line 402, in run
    func(args)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2client/commands/resource.py", line 48, in decorate
    return func(*args, **kwargs)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2client/commands/action.py", line 1203, in run_and_print
    return self._print_execution_details(execution=execution, args=args, **kwargs)
  File "/opt/stackstorm/st2/lib/python2.7/site-packages/st2client/commands/action.py", line 338, in _print_execution_details
    runner_type = execution.action.get('runner_type', 'unknown')
AttributeError: 'Execution' object has no attribute 'action'

@nmaludy
Copy link
Member Author

nmaludy commented Jan 18, 2019

Latest commit should address the st2client issues

@Kami
Copy link
Member

Kami commented Jan 22, 2019

It looks like some CLI tests are failing. I didn't have time to dig in yet (if it's related to this change or not).

EDIT: End to end tests are failing as well so it looks like a legit issues.

@Kami
Copy link
Member

Kami commented Mar 19, 2019

I pushed a small change and I believe this should now work correctly.

@CLAassistant
Copy link

CLAassistant commented Mar 19, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.

❌ Kami
❌ nmaludy
You have signed the CLA already but the status is still pending? Let us recheck it.

@Kami Kami force-pushed the feature/execution-get-attributes branch from 05795d8 to e36c976 Compare March 19, 2019 10:48
@Kami
Copy link
Member

Kami commented Mar 19, 2019

The diff got really large and messy so I needed to rebase this on top of master and force push to get it sorted out.

@Kami Kami merged commit 0b95862 into StackStorm:master Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants