Skip to content

Avoid hardcoded secrets name when checking OpenAI API Key #195

Open

Description

@stefanusgusega

Summary

I noticed that this tool assumed that OpenAI API Key is always stored in OPENAI_API_KEY secrets variable (https://github.com/anc95/ChatGPT-CodeReview/blob/dev/src/bot.ts#L21). I want to make this key can be stored with using flexible secrets variable name. This is recommended because the tool also initiated Chat object with OpenAI API Key fetched from environment variables, instead of directly to secrets variable (https://github.com/anc95/ChatGPT-CodeReview/blob/dev/src/bot.ts#L10).

This improvement should be good, because somehow the bot commented on the pull request indicating that I did not set OPENAI_API_KEY secrets variable (indeed I did not set it up, instead I set up the other variable). The PR can be seen on this link: stefanusgusega/sepotifai-retriever#2

Activity

  1. stefanusgusega commented on Sep 20, 2025

    @stefanusgusega
    Author

    I'm sorry, I think I probably misunderstood the code. So, the flow is: return Chat using process.env.OPENAI_API_KEY if any --> if not set, get OPENAI_API_KEY manually. Is it right?

  2. anc95 commented on Sep 22, 2025

    @anc95
    Owner

    @stefanusgusega yes. your understanding is correct, if OPENAI_API_KEY existing in ENV, then use it. if not, then trying to retrieve it from github variables

  3. stefanusgusega commented on Sep 23, 2025

    @stefanusgusega
    Author

    Okay, but in my following PR (stefanusgusega/sepotifai-retriever#2), I have set OPENAI_API_KEY on my ENV (https://github.com/stefanusgusega/sepotifai-retriever/blob/master/.github/workflows/review-bot.yml#L27), but I still get the message that I do not set the OpenAI API Key. Is it expecetd?

  4. anc95 commented on Sep 23, 2025

    @anc95
    Owner

    the github action looks working.

    yes, it's expected.

    if you are using github bot, it can only access the OPENAI_API_KEY in variables, so it raised the error. either you deploy the bot yourself with OPENAI_API_KEY env var or you have set OPENAI_API_KEY in variables, it should work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions