Repository: dbt-labs/dbt-core
Pull request: fix retry as CLI
Resolves: #9444
Our integration test right now goes through dbtRunner, which will add the `manifest` as None in `ctx.obj`.
When running retry as a CLI command, current code would just fail.

We should add some test to run each command as CLI command just to make sure CLI works.


Problem statement:
[Bug] Retry would failing running as a CLI command
### Is this a new bug in dbt-core?

- [X] I believe this is a new bug in dbt-core
- [X] I have searched the existing issues, and I could not find an existing issue for this bug

### Current Behavior

Running `dbt retry` will fail

### Expected Behavior

retry works

### Steps To Reproduce

run `dbt retry` in a project

### Relevant log output

```
23:11:40  Encountered an error:
'manifest'
23:11:40  Traceback (most recent call last):
  File "/Users/dbeatty/projects/environments/dbt_1.7/lib/python3.10/site-packages/dbt/cli/requires.py", line 91, in wrapper
    result, success = func(*args, **kwargs)
  File "/Users/dbeatty/projects/environments/dbt_1.7/lib/python3.10/site-packages/dbt/cli/requires.py", line 76, in wrapper
    return func(*args, **kwargs)
  File "/Users/dbeatty/projects/environments/dbt_1.7/lib/python3.10/site-packages/dbt/cli/requires.py", line 169, in wrapper
    return func(*args, **kwargs)
  File "/Users/dbeatty/projects/environments/dbt_1.7/lib/python3.10/site-packages/dbt/cli/requires.py", line 198, in wrapper
    return func(*args, **kwargs)
  File "/Users/dbeatty/projects/environments/dbt_1.7/lib/python3.10/site-packages/dbt/cli/requires.py", line 245, in wrapper
    return func(*args, **kwargs)
  File "/Users/dbeatty/projects/environments/dbt_1.7/lib/python3.10/site-packages/dbt/cli/main.py", line 652, in retry
    ctx.obj["manifest"],
KeyError: 'manifest'
```


### Environment

```markdown
- OS:
- Python:
- dbt: 1.7.5
```


### Which database adapter are you using with dbt?

_No response_

### Additional Context

_No response_

Hints from issue discussion:

Commit message: fix running things as CLI

Patch to review:
diff --git a/core/dbt/cli/main.py b/core/dbt/cli/main.py
index ad2fbf61a77..c1db298960b 100644
--- a/core/dbt/cli/main.py
+++ b/core/dbt/cli/main.py
@@ -608,7 +608,7 @@ def retry(ctx, **kwargs):
     task = RetryTask(
         ctx.obj["flags"],
         ctx.obj["runtime_config"],
-        ctx.obj["manifest"],
+        None,
     )
 
     results = task.run()


Code review comments:
diff_hunk: @@ -608,7 +608,7 @@ def retry(ctx, **kwargs):
     task = RetryTask(
         ctx.obj["flags"],
         ctx.obj["runtime_config"],
-        ctx.obj["manifest"],
path: core/dbt/cli/main.py
text: @user1:
Is it okay for the manifest to be `None`? Would it be safer to do something like `ctx.obj.get("manifest")` which returns either the object or `None`?

@author:
So the last refactor actually refactored parsing for retry into the task itself. So it would be alright to always pass in a None(which is what our intergration tests where doing before)

@user2:
We don't even use the manifest passed to the RetryTask's constructor at all at all: https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/task/retry.py#L66

This should be safe to entirely remove, we don't even need to pass `None`

@author:
Done!

@user1:
Awesome! Thanks y'all for the clarification 🙂 

@author:
Thanks for poking and resulting in better comment.