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

Private repositories can not be handled, missing auth #43

Open
Xerkus opened this issue Dec 3, 2021 · 4 comments
Open

Private repositories can not be handled, missing auth #43

Xerkus opened this issue Dec 3, 2021 · 4 comments

Comments

@Xerkus
Copy link

Xerkus commented Dec 3, 2021

🐛 Summary

Private repositories can not be processed due to check for lineage configuration never returning result from unauthenticated request:

def get_config(repo: Repository.Repository) -> Optional[dict]:
"""Read the lineage configuration for this repo without checking it out."""
config_url: str = f"https://raw.githubusercontent.com/{repo.full_name}/{repo.default_branch}/{CONFIG_FILENAME}"
logging.debug("Checking for config at: %s", config_url)
response = requests.get(config_url)
if response.status_code == 200:
return yaml.safe_load(response.content)
else:
return None

To reproduce

Steps to reproduce the behavior:

  1. Setup action normally for private repository scanning
  2. Setup private repository and ensure PAT provides access
  3. Declare lineage configuration in private repository
  4. Trigger action and ensure repository was scanned:
    INFO Querying for repositories: user:Xerkus archived:false
    Xerkus/private-lineage-test
      INFO Checking: Xerkus/private-lineage-test
      INFO Lineage configuration not found for Xerkus/private-lineage-test
    
  5. Make repository public and observe action working as expected

Expected behavior

Lineage action can get past the check for lineage configuration existence

Any helpful log output or screenshots

@mcdonnnj
Copy link
Member

mcdonnnj commented Dec 7, 2021

@Xerkus Would you try the improvement/use_github_api_for_all_access branch and see if things work as you expect?

@Xerkus
Copy link
Author

Xerkus commented Dec 7, 2021

Lineage configuration is found, but it fails at cloning the repo.

@mcdonnnj
Copy link
Member

mcdonnnj commented Dec 8, 2021

Lineage configuration is found, but it fails at cloning the repo.

Ahh, sorry. I made a poor assumption about cloning behavior so I apologize. I have made a composition branch for testing because the two changes needed to resolve your issues belong in their own PRs. Would you try the testing/private_repo_access branch and let me know if things work as you expect this time?

@Xerkus
Copy link
Author

Xerkus commented Dec 8, 2021

Yes, this issue is resolved in the testing/private_repo_access branch.

The error that I see now is #44 when trying to fetch the upstream:

  INFO Checking: Xerkus/private-lineage-test
  INFO Lineage configuration found for Xerkus/private-lineage-test
  INFO Cloning repository: https://github.com/Xerkus/private-lineage-test.git
  INFO ✅ success
  INFO Processing lineage: skeleton
  INFO Upstream: https://github.com/Xerkus/private-lineage-test.git HEAD
  INFO Attempting to switch to branch: lineage/skeleton
  INFO ✅ (error ok) return code: 128
  INFO Branch did not exist.  Creating: lineage/skeleton from local main
  INFO Creating branch lineage/skeleton from main
  INFO ✅ success
  INFO Switching to lineage/skeleton
  INFO ✅ success
  INFO Pull request branch is new: True
  INFO Fetching https://github.com/Xerkus/private-lineage-parent.git HEAD
  Traceback (most recent call last):
  CRITICAL fatal: could not read Username for 'https://github.com': No such device or address
  
  CRITICAL ❌ ERROR! return code: 128
    File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
      return _run_code(code, main_globals, None,
    File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
      exec(code, run_globals)
    File "/src/lineage/__main__.py", line 5, in <module>
      main()
    File "/src/lineage/entrypoint.py", line 455, in main
      fetch(repo, remote_url, remote_branch)
    File "/src/lineage/entrypoint.py", line 163, in fetch
      run([GIT, "fetch", remote_url, remote_branch], cwd=repo.full_name)
    File "/src/lineage/entrypoint.py", line 69, in run
      raise Exception("Subprocess was expected to exit with 0.")
  Exception: Subprocess was expected to exit with 0.

fetch(repo, remote_url, remote_branch)

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

No branches or pull requests

2 participants