pack icon indicating copy to clipboard operation
pack copied to clipboard

UX bug: Show a difference between zero args and empty args

Open schneems opened this issue 3 years ago • 14 comments

Summary

I ran into an issue where (due to a buildpack version difference) one buildpack was working and one wasn't. I figured out the problem eventually, but the core issue that made debugging harder than it had to be was that lifecycle currently shows the same output for empty args [] as it does for args that contain no characters [""].

$ pack inspect cutlass_image_basic_bash | grep -B2 web
Processes:
  TYPE                 SHELL        COMMAND        ARGS
  web (default)        bash         while true; do echo 'lol'; sleep 2; done

Note that there's nothing under the "args" section, and it collapses into the command.

Here's my original notes and investigation https://github.com/Malax/libcnb.rs/issues/49

Reproduction

Steps

Make a base buildpack:

cd /tmp
mkdir my_buildpack && cd my_buildpack
mkdir -p bin

cat > buildpack.toml <<EOM

api = "0.4"
[buildpack]
id = "ultra basic invoker"
version = "0.0.0"
name = "ultra basic invoker"

[[licenses]]
type = "MIT"

[[stacks]]
id = "heroku-20"

[metadata]
EOM

cat > bin/detect <<EOM
#!/usr/bin/env bash

exit 0
EOM

Write a build script with non-empty args

cat > bin/build <<EOM
#!/usr/bin/env bash

layers_dir=\$1

cat >> "\${layers_dir}/launch.toml" <<EOL
[[processes]]
type = "web"
command = "while true; do echo 'lol'; sleep 2; done"
args = [""]  # Non-empty args
direct = false
EOL
EOM
chmod +x bin/build
chmod +x bin/detect

Build it:

pack build debug_pack_inspect_launch_args --path . -B heroku/buildpacks:20 --buildpack ./  -v

Produces:

$ pack inspect debug_pack_inspect_launch_args | grep -B2 web
Processes:
  TYPE                 SHELL        COMMAND        ARGS
  web (default)        bash         while true; do echo 'lol'; sleep 2; done

Modify to empty args in the launch:

cat > bin/build <<EOM
#!/usr/bin/env bash

layers_dir=\$1

cat >> "\${layers_dir}/launch.toml" <<EOL
[[processes]]
type = "web"
command = "while true; do echo 'lol'; sleep 2; done"
args = []  # EMPTY args
direct = false
EOL
EOM

Build it:

pack build debug_pack_inspect_launch_args --path . -B heroku/buildpacks:20 --buildpack ./  -v

Produces:

$ pack inspect debug_pack_inspect_launch_args | grep -B2 web
Processes:
  TYPE                 SHELL        COMMAND        ARGS
  web (default)        bash         while true; do echo 'lol'; sleep 2; done

So even though the image produced is not identical, the output of pack inspect is.

Current behavior

Pack inspect does shows identical output when there are no args versus when there are args with no characters.

Expected

I expected the two to produce an observable/inspectable difference in outputs because they are different (one executes, and the other does not).

I propose possibly adding arg count to the output such as:

Processes:
  TYPE                 SHELL        COMMAND                                         ARGS (count = 0)
  web (default)        bash         while true; do echo 'lol'; sleep 2; done        

Or possibly showing non-visible args:

Processes:
  TYPE                 SHELL        COMMAND                                         ARGS (count = 1)
  web (default)        bash         while true; do echo 'lol'; sleep 2; done     ""

Context

lifecycle version

Lifecycle: Version: 0.11.4

platform version(s)
$ pack report
Pack:
  Version:  0.20.0+git-66a4f32.build-2668
  OS/Arch:  darwin/amd64

Default Lifecycle Version:  0.11.3

Supported Platform APIs:  0.3, 0.4, 0.5, 0.6

Config:
(no config file found at /Users/rschneeman/.pack/config.toml)

schneems avatar Sep 13 '21 19:09 schneems

@schneems thanks for reporting this! I suspect the root issue is in pack, as pack is reading the processes information from the io.buildpacks.build.metadata label and on the app that I tested, I see \"args\":[\"\"] there. I could move it over to the pack repo if there are no objections.

natalieparellano avatar Sep 13 '21 19:09 natalieparellano

@natalieparellano thank you, if you can move it over that would be amazing!

schneems avatar Sep 13 '21 20:09 schneems

Instead of a count of the args (which seems a bit out of place in all but the zero args case), another option might be to show <NONE> or similar in the no-args case.

@schneems Also, I wonder if (as part of another issue) lifecycle should forbid empty string args given they seem to not be able to successfully launch the command, from what you found the other day?

edmorley avatar Sep 13 '21 22:09 edmorley

Also, I wonder if (as part of another issue) lifecycle should forbid empty string args given they seem to not be able to successfully launch the command, from what you found the other day?

For my case that would be great. I think there might be another case where someone writes a bash tool that needs an empty arg. If we raised/disallowed an empty arg then also including some kind of escape valve. For example allow_empty_arg: true in the launch.toml

schneems avatar Sep 16 '21 16:09 schneems

I want to work on this issue. @natalieparellano can you please assign this issue to me ?

rizul2108 avatar Jan 23 '24 18:01 rizul2108

Hi @rizul2108 thanks for helping us out

jjbustamante avatar Jan 24 '24 13:01 jjbustamante

@rizul2108 before you try to fix this one, could you try to reproduce it with the latest main branch version? We just merged this PR, that I think it could be related but I didn't check. I do not want you to waste your time

jjbustamante avatar Jan 24 '24 13:01 jjbustamante

Ok sure I will check once

rizul2108 avatar Jan 25 '24 17:01 rizul2108

image Screenshot from 2024-01-27 18-12-13 yes it is still giving same output

rizul2108 avatar Jan 27 '24 12:01 rizul2108

so i should start work on fixing this this error? @jjbustamante

rizul2108 avatar Jan 27 '24 12:01 rizul2108

Hi @rizul2108 , yes!

I like the idea suggested by Ed here, to use <NONE> with no-args case

jjbustamante avatar Jan 29 '24 15:01 jjbustamante

Okk sure I will work on it

rizul2108 avatar Jan 29 '24 15:01 rizul2108

Hi @rizul2108!

Are you still working on this one?

jjbustamante avatar Mar 05 '24 16:03 jjbustamante