← All solutions

The Mammal Generator Challenge — Solution

This process documents the steps to solve "The Incident Challenge Week #2 - Mammal Generator"

1. Introduction

The PRD doc describes the intent of the feature - Generating a cat with a hat.

Introduction

2. Staging Environment

Let's view staging

Staging Environment

3. Generate

Clicking "Generate" gives us indeed A cat with a hat (as expected)

![Generate](/ solutions/challenge-2/step-03.png)

4. Production

Let's identify the problem in production.

Production

5. Generate

Clicking "Generate" gives us a Dog with a mustache....

Generate

6. Source Code Investigation

Let's investigate the issue through the source code on GitHub

Source Code Investigation

7. Navigate to GitHub Repository

Navigate to GitHub Repository

8. View image-gen main.py

After viewing the main file of the image generator service to try to trace where the animal is coming from.
We can see the function is trying to fetch a "Default media subject" from the db.

View image-gen main.py

9. Second clue

As well as a suspicious SELECT prompt FROM .....

Let's save both the queries and get back to the challenge interface.

Second clue

10. Switch back to the Interface

Switch back to the Interface

11. Review SQL Query Results

Let's try to run the first query.

We notice the results indeed shows different default values between staging and production.

Review SQL Query Results

12. Second query (Prompt)

Using the ids we retrieved, let's try to query the prompts themselves.

We indeed see a prompt of a "dog"

Second query (Prompt)

13. Accessory Query

Now let's query the accessory prompt.

And we indeed see a mustache!

Accessory Query

14. Update production default subject

After we got the subject values, let's replace production subject default value with the one from staging.

Update production default subject

15. Update production default accessory

Now do the same for accessory

Update production default accessory

16. Update results

Both columns updated!

Update results

17. Generate again

Let's generate again

Generate again

18. Results

Now we do see a cat, only without a hat :(

Results

19. Go back to the prompt builder code

In the prompt service, let's view the main function 'build_prompt' (could be related...)

Go back to the prompt builder code

20. Headwear hiding

We do see a weird condition for hiding headwear...

Headwear hiding

21. Feature toggle

Inspecting the function, gives us a query for fetching feature toggles (per environment)

Feature toggle

22. Switch to challenge Interface

Switch to challenge Interface

23. Run the feature toggle query

Run the feature toggle query

24. Update production values

Let's update production values (1) with the value from staging (0)

Update production values

25. Generate again

Generate again

26. Yay!! The cat with the hat shows

Let's submit!

Yay!! The cat with the hat shows

You're done, see you next week.