Error en lab: bug_clarifier.py exited with status code 1

I am working on the “Bug Description Clarifier” lab. My script bug_clarifier.py is supposed to take a bug description and send it to the OpenAI API to generate a structured summary.

However, when I run or validate the lab, I get the following error:

'bug_clarifier.py' exited with a non-zero status code: 1
import os
from openai import OpenAI

# Initialize client using environment variables
client = OpenAI(
    api_key=os.getenv("OPENAI_API_KEY"),
    base_url=os.getenv("OPENAI_API_BASE")
)

def clarify_bug(description: str) -> str:
    # Dynamic prompt
    prompt = f"""
You are an AI assistant that rewrites informal bug reports into clear, structured, and professional issue summaries.

Rewrite the following bug report with:
- A clear title
- Steps to reproduce
- Expected behavior
- Actual behavior

Bug report:
"{description}"
"""

    # API call
    response = client.chat.completions.create(
        model="openai/gpt-4.1-mini",
        messages=[
            {"role": "user", "content": prompt}
        ],
        max_tokens=100,
        temperature=0.0
    )

    # Return generated text
    return response.choices[0].message.content


if __name__ == "__main__":
    # Lab input
    bug_description = "App keeps crashing when I click save."

    # Get result
    clarified = clarify_bug(bug_description)

    # Store in response variable (as required)
    response = clarified

    # Print output
    print(response)

Environment:

  • Python 3.x
  • openai library installed with pip install openai
  • Environment variables loaded from /root/.bash_profile

What I have tried:

  • Verified that OPENAI_API_KEY and OPENAI_BASE_URL are set
  • Ran source /root/.bash_profile
  • Tried adding exception handling, but the validator only shows exit code 1

Question:
What could be causing this error, and how can I properly debug it within the lab environment?

Hi @fsialercloud

Thanks for your feedback.

I also couldn’t complete the task and got the same error. I’ll check with the team and keep you updated.

1 Like