Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add array check for listRepoContents when it's Not Found #10

Merged
merged 2 commits into from
Nov 8, 2023

Conversation

PineappleIOnic
Copy link
Contributor

@PineappleIOnic PineappleIOnic commented Nov 8, 2023

After selecting a repository, we run listRepositoryContents() to get the runtime. If the repository is empty, we get this response:

["status-code"]=>
    int(404)
  }
  ["body"]=>
  array(2) {
    ["message"]=>
    string(25) "This repository is empty."
    ["documentation_url"]=>
    string(55) "https://docs.github.com/v3/repos/contents/#get-contents"
  }
}

This, then results in:

Cannot access offset of type string on string: null
#5 null(null): Utopia\VCS\Adapter\Git\{closure}
#4 /usr/src/code/vendor/utopia-php/vcs/src/VCS/Adapter/Git/GitHub.php(192): array_map
#3 /usr/src/code/app/controllers/api/vcs.php(491): listRepositoryContents
#2 /usr/src/code/vendor/utopia-php/framework/src/App.php(508): {closure}
#1 /usr/src/code/vendor/utopia-php/framework/src/App.php(673): execute
#0 /usr/src/code/app/http.php(253): run

This PR updates listRepositoryContents() to return an empty array when we receive status 404.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants