Skip to content

codeflash init fails with an Access denied when trying to make request to Codeflash API #1039

@kratsg

Description

@kratsg

I followed the instructions in the documentation and installed the GitHub App:

Image

Here is the following output and I'm not sure what else I can do.

$ codeflash init
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
╭─────────────────────── https://codeflash.ai ───────────────────────╮
│                                                                    │
│                    _          ___  _               _               │
│                   | |        / __)| |             | |              │
│   ____   ___    _ | |  ____ | |__ | |  ____   ___ | | _            │
│  / ___) / _ \  / || | / _  )|  __)| | / _  | /___)| || \           │
│ ( (___ | |_| |( (_| |( (/ / | |   | |( ( | ||___ || | | |          │
│  \____) \___/  \____| \____)|_|   |_| \_||_|(___/ |_| |_|          │
│                                                            v0.19.1 │
│                                                                    │
│                                                                    │
╰────────────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────────────────── 🚀 Codeflash Setup ────────────────────────────────────────────────────────────╮
│                                                                                                                                            │
│                                                          ⚡️ Welcome to Codeflash!                                                          │
│                                                                                                                                            │
│                                                  This setup will take just a few minutes.                                                  │
│                                                                                                                                            │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

╭───────────────────────────────────────────────────────────── 🔑 API Key Found ─────────────────────────────────────────────────────────────╮
│                                     🔑 I found a CODEFLASH_API_KEY in your environment [cf-****LPbI]!                                      │
│                                                                                                                                            │
│                                                 ✅ You're all set with API authentication!                                                 │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

✅ A valid Codeflash config already exists in this project. Do you want to re-configure it? [y/n] (n):
🐙 Looks like you've already installed the Codeflash GitHub app on this repository (scipp-atlas/pyhs3)! Continuing…
╭──────────────────────────────────────────────────────── 🤖 Continuous Optimization ────────────────────────────────────────────────────────╮
│ 🤖 GitHub Actions Setup                                                                                                                    │
│                                                                                                                                            │
│ GitHub Actions will automatically optimize your code in every pull request. This is the recommended way to use Codeflash for continuous    │
│ optimization.                                                                                                                              │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

[?] Set up GitHub Actions for continuous optimization? We'll open a pull request with the workflow file. (Y/n):
INFO     [cmd_init.py:install_github_actions] User confirmed, generating workflow content...
Creating PR with GitHub Actions workflow...
INFO     [cmd_init.py:install_github_actions] Calling setup_github_actions API for scipp-atlas/pyhs3 on branch main
ERROR    CF_API_Error:: making request to Codeflash API (url: https://app.codeflash.ai/cfapi/setup-github-actions, method: POST, status 403):
         Access denied
ERROR    [cmd_init.py:install_github_actions] Permission denied for scipp-atlas/pyhs3
╭───────────────────────────────────────────────────────────── ❌ Setup Failed ──────────────────────────────────────────────────────────────╮
│ ❌ Access Denied                                                                                                                           │
│                                                                                                                                            │
│ The GitHub App may not be installed on scipp-atlas/pyhs3, or it doesn't have the required permissions.                                     │
│                                                                                                                                            │
│ 💡 To fix this:                                                                                                                            │
│ 1. Install the CodeFlash GitHub App on your repository                                                                                     │
│ 2. Ensure the app has 'Contents: write', 'Workflows: write', and 'Pull requests: write' permissions                                        │
│ 3. Make sure you have write access to the repository                                                                                       │
│                                                                                                                                            │
│ 🔗 Install GitHub App: https://github.com/apps/codeflash-ai/installations/select_target                                                    │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Please install the CodeFlash GitHub App and ensure it has the required permissions.
Visit: https://github.com/apps/codeflash-ai/installations/select_target

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
INFO     💡 If you're having trouble, see https://docs.codeflash.ai/getting-started/local-installation for further help getting started with
         Codeflash!
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
INFO     👋 Exiting...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions