Repository: dbt-labs/dbt-core

Issue:
[CT-3377] [Regression] `dbt deps` fails on tarball dependencies
### Is this a regression in a recent version of dbt-core?

- [X] I believe this is a regression in dbt-core functionality
- [X] I have searched the existing issues, and I could not find an existing issue for this regression

### Current Behavior

When `dependencies.yml` includes a tarball dependency, I get an error message from `dbt deps`:

```
11:18:06  Running with dbt=1.7.1
11:18:06  Updating lock file in file path: /workspace/dbt-deps-tarball-failure/asdf/package-lock.yml
11:18:06  Encountered an error:
Runtime Error
  The packages.yml file in this project is malformed. Please double check
  the contents of this file and fix any errors before retrying.
  
  You can find more information on the syntax for this file here:
  https://docs.getdbt.com/docs/package-management
  
  Validator Error:
  dbt_utils was not found in the package index. Packages on the index require a namespace, e.g dbt-labs/dbt_utils
```

### Expected/Previous Behavior

Expected output:
```
11:27:03  Running with dbt=1.6.8
11:27:03  Installing dbt_utils
11:27:03  Installed from tarball (url: https://codeload.github.com/dbt-labs/dbt-utils/tar.gz/0.9.6)
```

The validator should 
- not check the index for tarball dependencies
- not validate the `namespace/package-name` for tarball dependencies
- mention the correct filename (this is a minor thing)

### Steps To Reproduce

1. In a new dbt project
2. With the following `dependencies.yml`:
```yaml
packages:
  - tarball: https://codeload.github.com/dbt-labs/dbt-utils/tar.gz/0.9.6
    name: 'dbt_utils'
```
3. Run `dbt deps`
4. See error message above

### Relevant log output

_No response_

### Environment

```markdown
- OS: Ubuntu 22.04.3
- Python: 3.11.1
- dbt-core (latest working version): 1.6.8
- dbt-core (earliest regression version): 1.7.0
- dbt-core (latest version): 1.7.1
```


### Which database adapter are you using with dbt?

_No response_

### Additional Context

_No response_


Discussion:

Resolving patch:
diff --git a/core/dbt/deps/tarball.py b/core/dbt/deps/tarball.py
--- a/core/dbt/deps/tarball.py
+++ b/core/dbt/deps/tarball.py
@@ -31,8 +31,7 @@ def name(self):
     def to_dict(self) -> Dict[str, str]:
         return {
             "tarball": self.tarball,
-            "version": self.version,
-            "package": self.package,
+            "name": self.package,
         }
 
     def get_version(self):


Test patch:
diff --git a/tests/functional/dependencies/test_simple_dependency.py b/tests/functional/dependencies/test_simple_dependency.py
--- a/tests/functional/dependencies/test_simple_dependency.py
+++ b/tests/functional/dependencies/test_simple_dependency.py
@@ -4,9 +4,11 @@
 
 from pathlib import Path
 
+from dbt.exceptions import DbtProjectError
 from dbt.tests.util import (
     check_relations_equal,
     run_dbt,
+    write_config_file,
 )
 
 
@@ -374,3 +376,42 @@ def test_deps_bad_profile(self, project):
         del os.environ["PROFILE_TEST_HOST"]
         run_dbt(["deps"])
         run_dbt(["clean"])
+
+
+class TestSimpleDependcyTarball(object):
+    @pytest.fixture(scope="class")
+    def packages(self):
+        return {
+            "packages": [
+                {
+                    "tarball": "https://codeload.github.com/dbt-labs/dbt-utils/tar.gz/0.9.6",
+                    "name": "dbt_utils",
+                }
+            ]
+        }
+
+    def test_deps_simple_tarball_doesnt_error_out(self, project):
+        run_dbt(["deps"])
+        assert len(os.listdir("dbt_packages")) == 1
+
+
+class TestBadTarballDependency(object):
+    def test_malformed_tarball_package_causes_exception(self, project):
+        # We have to specify the bad formatted package here because if we do it
+        # in a `packages` fixture, the test will blow up in the setup phase, meaning
+        # we can't appropriately catch it with a `pytest.raises`
+        bad_tarball_package_spec = {
+            "packages": [
+                {
+                    "tarball": "https://codeload.github.com/dbt-labs/dbt-utils/tar.gz/0.9.6",
+                    "version": "dbt_utils",
+                }
+            ]
+        }
+        write_config_file(bad_tarball_package_spec, "packages.yml")
+
+        with pytest.raises(
+            DbtProjectError, match=r"The packages.yml file in this project is malformed"
+        ) as e:
+            run_dbt(["deps"])
+            assert e is not None