Repository: iterative/dvc

Issue:
push: error on cloud versioning push
# Bug Report

## Description

Getting an error when trying to push using cloud versioning.

### Reproduce

1. Set up an s3 path to use as a remote.
2. Clone git@github.com:iterative/example-get-started.git
3. Pull from the remote.
4. Add/modify a remote to use the s3 path and the `version_aware` and `worktree` options.
5. Push to this remote.

Output:

```
$ dvc push -v
2022-09-15 13:23:41,618 DEBUG: built tree 'object 153aad06d376b6595932470e459ef42a.dir'
2022-09-15 13:23:43,498 DEBUG: built tree 'object f35d4cc2c552ac959ae602162b8543f3.dir'
2022-09-15 13:23:47,834 DEBUG: built tree 'object 153aad06d376b6595932470e459ef42a.dir'
2022-09-15 13:23:48,507 DEBUG: built tree 'object f35d4cc2c552ac959ae602162b8543f3.dir'
2022-09-15 13:23:51,384 ERROR: unexpected error - cannot unpack non-iterable NoneType object
------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/dave/Code/dvc/dvc/cli/__init__.py", line 185, in main
    ret = cmd.do_run()
  File "/Users/dave/Code/dvc/dvc/cli/command.py", line 22, in do_run
    return self.run()
  File "/Users/dave/Code/dvc/dvc/commands/data_sync.py", line 59, in run
    processed_files_count = self.repo.push(
  File "/Users/dave/Code/dvc/dvc/repo/__init__.py", line 49, in wrapper
    return f(repo, *args, **kwargs)
  File "/Users/dave/Code/dvc/dvc/repo/push.py", line 77, in push
    return _push_worktree(self, _remote)
  File "/Users/dave/Code/dvc/dvc/repo/push.py", line 41, in _push_worktree
    _, hash_info = old_tree.get(
TypeError: cannot unpack non-iterable NoneType object
------------------------------------------------------------
2022-09-15 13:23:52,197 DEBUG: Removing '/private/tmp/.HGMEebVYS4QqjyfVsHFXxt.tmp'
2022-09-15 13:23:52,198 DEBUG: Removing '/private/tmp/.HGMEebVYS4QqjyfVsHFXxt.tmp'
2022-09-15 13:23:52,198 DEBUG: Removing '/private/tmp/.HGMEebVYS4QqjyfVsHFXxt.tmp'
2022-09-15 13:23:52,198 DEBUG: Removing '/private/tmp/example-get-started/.dvc/cache/.98iu3M9JWK5Q6WfJyHcHe7.tmp'
2022-09-15 13:23:52,199 DEBUG: Version info for developers:
DVC version: 2.26.1.dev2+gf854fc636
---------------------------------
Platform: Python 3.10.2 on macOS-12.5.1-arm64-arm-64bit
Subprojects:
        dvc_data = 0.8.0
        dvc_objects = 0.2.2
        dvc_render = 0.0.10
        dvc_task = 0.1.2
        dvclive = 0.10.0
        scmrepo = 0.1.1
Supports:
        azure (adlfs = 2022.7.0, knack = 0.9.0, azure-identity = 1.7.1),
        gdrive (pydrive2 = 1.14.0),
        gs (gcsfs = 2022.8.2),
        hdfs (fsspec = 2022.8.2, pyarrow = 7.0.0),
        http (aiohttp = 3.8.1, aiohttp-retry = 2.8.3),
        https (aiohttp = 3.8.1, aiohttp-retry = 2.8.3),
        oss (ossfs = 2021.8.0),
        s3 (s3fs = 2022.8.2, boto3 = 1.24.59),
        ssh (sshfs = 2022.3.1),
        webdav (webdav4 = 0.9.4),
        webdavs (webdav4 = 0.9.4),
        webhdfs (fsspec = 2022.8.2)
Cache types: reflink, hardlink, symlink
Cache directory: apfs on /dev/disk3s1s1
Caches: local
Remotes: s3
Workspace directory: apfs on /dev/disk3s1s1
Repo: dvc, git
```

**Additional Information (if any):**

Even if I try to push a single file, I get the same error. It looks like the data was pushed, but the version ids are not added to my local dvcfiles.


Discussion:

 Was trying with example-get-started too today and run into the same error. 
 Ah, nevermind, getting a different one with azure.

Resolving patch:
diff --git a/dvc/stage/loader.py b/dvc/stage/loader.py
--- a/dvc/stage/loader.py
+++ b/dvc/stage/loader.py
@@ -71,6 +71,8 @@ def fill_from_lock(stage, lock_data=None):
             item.meta = Meta.from_dict(info)
             hash_value = getattr(item.meta, item.hash_name, None)
             item.hash_info = HashInfo(item.hash_name, hash_value)
+            if item.hash_info and item.hash_info.isdir:
+                item.meta.isdir = True
 
     @classmethod
     def load_stage(cls, dvcfile, name, stage_data, lock_data=None):


Test patch: