origin: oc returns empty list with -o yaml when resource is missing

oc started behave inconsistently returning empty resource list instead of error when option -o yaml is provided. This is a breaking change from before and inconsistent for scripting - i.e. script expects a Resource object or error, while now it gets an empty resource list. Also it is inconsistent for command to return different error status depending on output format requested by user.

@pruan-rht , @liggitt , @ncdc

Version

oc v1.3.0-alpha.2-217-g1ca61fb

Steps To Reproduce
  1. create project
  2. oc get pod noonehere -o yaml
Current Result
      apiVersion: v1
      items: []
      kind: List
      metadata: {}
Expected Result
 Error from server: pods "hello-openshift" not found

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 28 (28 by maintainers)

Most upvoted comments

And what if you kubectl get pod/a pod/b?

In case 2: List (you requested multiple) printed to stdout, error to stderr, non-zero return

In case 3: Nothing to stdout, error to stderr, non-zero return

if all operations error, I would not expect an empty json/yaml list