Skip to main content

Updated for Fall 2026

This workshop is part of Milestone 0 — see that page for the milestone’s deliverables, rubric, and deadlines.

Expectations

In this workshop, we’ll look at debugging web applications built with Spring, Hibernate, and React, as well as the general debugging process followed throughout CSC 326. You will see how to find and fix bugs in several layers of the system, the tools that help make this a straightforward process, and what good process for finding, reporting, fixing, and testing bugs looks like.

Work through the workshop with at least one other person in your lab, following the CSC 326 GitHub Processes. The work itself is completed in your individual repository.

The workshop is designed to be completed without AI — the three bugs are there for you to hunt down with a debugger, because that skill does not transfer from watching a tool do it. AI is welcome in the independent bug hunt, with limits described there.

Activity: Debugging Workshop

You will complete the workshop to find and fix three bugs with others in your lab. This will help you explore issues, branching, pull requests, and merging.

Creating a development Branch

Good software engineering practice says that you never commit directly to the main branch of your project that contains the working copy of your code. Instead, best practice is to create separate “feature branches” that are used for implementing individual features or fixing individual bugs. We’ll be following said practice here and doing exactly that.

First, let’s make sure we’re on the right branch. From your terminal where the project was cloned, run git status. You should see an output similar to:

$ git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

The main branch is now reserved for complete, delivered code.

We will now start completing development activities in other branches! We need to create a new branch. Go to the GitHub web interface for your repository, and create a new branch called development.

  • Select the drop-down currently listing main.
  • Type development into the box.
  • Select the option to “Create branch: development from ‘main’”

If your Github repository already has a development branch, you can skip this and go directly to checking it out in the next step.

development is typically used for creating a staging branch shared across multiple members of a team, where individual features and bug fixes are combined together. All changes will funnel to development for integration testing. Then completed code can be merged from development to main for delivery (and grading).

Once you make the branch in Github, return to your terminal window and run git pull. This will fetch the new branch from upstream and make our local copy realize that there’s something new here.

Then, check out your new development branch by running git checkout development. If you run git status again, you should see:

$ git status
On branch development
Your branch is up to date with 'origin/development'.

nothing to commit, working tree clean

Back in IntelliJ, confirm that you are on the new branch. The Git branch widget shows the current branch — it is in the main toolbar in the new UI, or in the status bar along the bottom in the classic UI — and should now read development. You can also open the Git tool window with View > Tool Windows > Git (Alt+9) to see your branches and commit history.

Documenting the Bugs

As we find bugs, we’re going to document them in GitHub Issues.

Check out the class slides for information on how to make a good bug report (reproduce, isolate, generalize). Create an Issue for each of the two failing tests. You can update the Issue as you find out more about the bug.

Creating Branches for Issues

Professional software developers work on small portions of functionality at a time. This is helpful by focusing on one task and for removing changes that lead to problems. Developers will typically work on fixing one Issue. Issues can represent a failing test, a bug, a new feature, a task, etc. And to isolate the work, we create a branch to work on each issue.

Good branch names include the name of the developer responsible for them and a short description of the associated issue. In the setup, we found a bug when attempting to create a recipe via the POST /api/recipes endpoint. We could create a branch called unityid/recipe_not_created or similar if the person associated with unityid is the owner of the branch.

You can create branches via the GitHub website, via the command line, or through IntelliJ. All three are described below. Since you already created the development branch via the GitHub website earlier, try creating a branch through the command line and IntelliJ when prompted to create a branch.

GitHub Website

  • Start by selecting the branch you want to branch from. In this case, start with the development branch.
  • Type in the new branch name
  • Select the option to “Create branch: {branch name} from ‘development’”

Command Line

Run the following commands.

  • Ensure that you’re on the development branch.
$ git status
On branch development
Your branch is up to date with 'origin/development'.
  • If you’re not on the development branch, checkout the development branch.
$ git checkout development
$ git status
On branch development
Your branch is up to date with 'origin/development'.
  • Create the new branch.
$ git branch {branch name}
  • Verify the new branch is there. Note that the * by development shows that as the active branch.
$ git branch
* development
  main
  unityid/incorrect_inventory_consumed

IntelliJ watches the file system and picks up Git changes on its own. If the branch widget does not seem current, use File > Reload All from Disk (Ctrl+Alt+Y).

IntelliJ

Complete the following steps to create a branch:

  • Make sure that you’re in the branch you want to branch from (e.g., you should be in the development branch to make a bug fix branch.)
  • Open the Git popup by clicking the Git widget (main toolbar in the new UI, status bar in the classic UI). You can also use Git > Branches… in the top level menu.
  • Select Add Branch.
  • Enter the appropriate name.
  • You can uncheck the option to Checkout branch if you don’t want to switch to that branch right away.
  • Click Create.

Bug Hunt!

The CoffeeMaker project doesn’t currently have any automated tests. You’ll work on those soon. In the meantime, we can system test both our backend and frontend to find bugs.

Setup

When testing, it’s a good idea to start with a clean slate. We’re going to drop the database.

  1. Open MySQL Workbench and connect to your database system.
  2. Right click on the coffee_maker data base and select Drop Schema.
  3. Click Drop Now.
  4. Stop and start the backend.

Backend Recipe Creation Bug

System Test

Let’s start with a system test to see the backend recipe creation failure.

  1. Make sure the backend is running and open Postman.

  2. Call the POST /api/recipes endpoint. Pass in the information for a new Coffee recipe that cost 50 cents and has 3 units of coffee and 0 of all other ingredients. Click Send.

The result returns a 200 OK response, but the id for the recipe is null. It shouldn’t be. The id field is auto generated when the recipe is added to the database. A null value suggests there’s a problem.

We can check the database to be sure.

  1. Open MySQL Workbench.
  2. Double click the coffee_maker schema so it becomes bold. This is the same as running the command use coffee_maker.

The result grid shows an empty table. The recipe wasn’t added!

TODO: Bug Report

Write a bug report for the backend recipe creation bug.

TODO: Create a Branch

From the development branch, create a branch unityid/recipe_not_created or a similar name for fixing this bug. Switch to the bug fix branch.

Code Review

API endpoints correspond to methods in the *Controller classes in the backend. You can find the *Controller classes in the edu.ncsu.csc326.coffee_maker.controllers package under the src/main/java folder. We’ll start our code review there.

Open up the edu.ncsu.csc326.coffee_maker.controllers.RecipeController class (it’s in the src/main/java folder), and then scroll until you reach the createRecipe() method (or use the Outline view). This method provides the implementation for the API endpoint that our test just called. At this point, we don’t expect that you would know to look in the RecipeController class to fix this bug. The connections between the API call in the test and this method will be described more fully later.

This method is doing the following tasks:

  • Checking for a duplicate recipe name. If there is one, then an HttpStatus.CONFLICT is returned. This is the response code 409.
  • Checking that there is space for another recipe since we are limited to 3. If there is space, we ask the RecipeService to create the recipe and return a response of 200, which means everything is OK.
  • If there isn’t space, an HttpStatus.INSUFFICIENT_STORAGE is returned. This is the response code of 507.

Our test returned a response of 200, so we did call the code to create the recipe in the RecipeService class. Let’s take a look at RecipeService.

RecipeService is an interface in the edu.ncsu.csc326.coffee_maker.services package. The implementation of the interface is in the edu.ncsu.csc326.coffee_maker.services package. Open up RecipeServiceImpl and find the createRecipe method.

The method is doing the following tasks:

  • Transforming the RecipeDto object to a Recipe DAO object. Data Transfer Objects (DTOs) are for transferring data between layers. Data Access Objects (DAOs) are for interacting with the database. We use the *Mapper classes to transfer between these two types. They are POJOs with some annotations to support their roles in the system.
  • We then return the Recipe DAO object transformed into a RecipeDto object.

This method is currently transforming a DTO to a DAO and transforming it back without doing anything in between!

What do we do in between the transformations? We need to save the changes to the database and then send the saved version back to the controller.

TODO: Bug Fix

Update createRecipe to the following:

	@Override
	public RecipeDto createRecipe(RecipeDto recipeDto) {
		Recipe recipe = RecipeMapper.mapToRecipe(recipeDto);
		Recipe savedRecipe = recipeRepository.save(recipe);
		return RecipeMapper.mapToRecipeDto(savedRecipe);
	}

Save and restart the backend. Then call the POST /api/inventory endpoint again. The returned recipe has an id!

We can also see it in the database!

TODO: Commit and Push Changes to Remote

Commit and push your code, including the new branch to the remote. Make sure you include the Issue number in your commit message.

Backend MakeRecipe Bug

System Test

There’s a bug in the make recipe functionality. Let’s first run through the system test to uncover the bug.

  1. Make sure the backend is running and open Postman.

  2. We need to first call the GET /api/inventory endpoint. This initializes the database with an inventory of 0 for each of the 4 ingredients in the system. The endpoint returns the inventory contents with a 200 OK response.

  1. We need inventory to make a recipe. Update the inventory with the PUT /api/inventory endpoint.

  1. Now that we have a recipe (Coffee from the prior bug fix) and inventory, we can make a recipe. Call the POST /api/makerecipe/Coffee end point. We’ll enter 100 into the request body. We should recieve 50 in change.

  2. Making coffee worked - or at least we received the correct change. Let’s check the inventory. Call the GET /api/inventory endpoint. Oh no! The inventory was taken from the wrong ingredient!

TODO: Bug Report

Write a bug report for the backend make recipe bug.

TODO: Create a Branch

From the development branch, create a branch unityid/incorrect_inventory_consumed or a similar name for fixing this bug. Switch to the bug fix branch.

Code Review

Like the Backend Recipe Creation bug, we’ll start with the controller - MakeRecipeController.

Let’s review MakeRecipeController.makeRecipe.

  • We first get a RecipeDto object by name.
  • We then make the recipe by calling the private helper method.
    • We get the InventoryDto
    • We check that there’s enough money to purchase the recipe.
    • If so, we try to make the recipe.
    • If we make the recipe, we return the change.
    • If we can’t make the recipe, there’s not enough inventory.
    • If there’s not enough money to pay for the recipe, we refund the amount paid.
  • We return a response based on the outcome:
    • Not enough money: HttpStatus.CONFLICT + amtPaid
    • Not enough inventory: HttpStatus.BAD_REQUEST + amtPaid
    • Success: HttpStatus.OK + change

From our test we can see that we received change, so we followed the success path. But something is still wrong with the inventory. Let’s explore the MakeRecipeServiceImpl class to see where the inventory is modified.

We start with the MakeRecipeServiceImpl.makeRecipe() method.

  • We get the DAO for Recipe and inventory
  • We check if there are enough ingredients. We’ll skip investigating this because we didn’t see an error with ingredients.
  • We then update the ingredients by subtracting the ingredient in the recipe from the ingredient in the inventory.
  • We save the inventory and return true.

Do you see the bug? Make sure that all the ingredient names match in each line.

TODO: Bug Fix

Fix the bug and run a test to make sure the inventory is updating correctly.

TODO: Commit and Push Changes to Remote

Commit and push your code, including the new branch to the remote. Make sure you include the Issue number in your commit message.

Frontend Delete Recipe Bug

System Test

Switch to the branch you created to fix the Backend Recipe Creation bug. Now that we can create recipes, we can fix the bug in the frontend when we try to delete recipes (the DELETE /api/recipes/{id} endpoint works, but you’re welcome to test that too).

  1. Restart the backend.
  2. Start the frontend.
  3. Navigate to http://localhost:3000
  4. Click the Delete button next to the Coffee recipe.

Nothing is deleted!

TODO: Bug Report

Write a bug report for the frontend delete recipe bug.

TODO: Create a Branch

Since this bug fix depends on fixing the Backend Create Recipe bug, we’ll branch from the branch you used to fix that bug (e.g., unityid/recipe_not_created or something like that). Switch to that branch and create a new branch unityid/recipe_not_deleted or a similar name for fixing this bug. Switch to the bug fix branch.

Code Review

Let’s explore a bit more what’s going on in the frontend. Restart your backend and frontend and navigate to http://localhost:3000.

Hit F12 to open up the developer tools. This will give you access to the DOM (Document Object Model, the unrendered structure of the page), the browser console (which functions similarly to the Run and Debug consoles in IntelliJ), a primitive debugger (under the Sources) tab, and a view of what networks requests were made while loading the page. Note that your tools may look slightly different depending on which browser you’re working with.

Let’s start with the Console tab. This shows output from the application, including things that you might log. For example, in components/ListRecipesComponent.jsx the removeRecipe function has both an info log (console.log(id)) and an error log (console.error(error)).

Click the Delete button by the recipe. Two errors are displayed in the console log.

These errors are letting us know that the API call associated with the delete button resulted in a 404 (Not Found)result. We can also see the API call made, which in this case was GET /api/recipes/1. We can also see the call stack. RecipesService.js called the backend API via the deleteRecipe() function; ListRecipesComponent.removeRecipe() called the service; and the button’s onClick() function called the removeRecipe() function.

The concern is that we’re trying to delete something with a GET API call. If you want to delete something, you need to use a DELETE API call. Let’s investigate RecipesService.js.

The deleteRecipe function is working with axios.get! axios is a library for making REST API calls. That object works with the standard HTTP requests of GET, POST, PUT, and DELETE. We called the wrong method!

TODO: Bug Fix

Update RecipesService.js deleteRecipe function to the following.

export const deleteRecipe = (id) => axios.delete(REST_API_BASE_URL + "/" + id)

Once you save, the frontend server will integrate the changes. Go back to the browser to delete the recipe.

TODO: Commit and Push Changes to Remote

Commit and push your code, including the new branch to the remote. Make sure you include the Issue number in your commit message.

Integrating Bugfixes

Now that we’ve gotten each of these bugs fixed individually, it’s time to integrate all of the fixes together and make sure that the entire project works.

Go to the Pull Requests tab within your Github repository, and click on the green New Pull Request button. “Pull Requests”, despite their confusing name, are used to merge code from one branch to another branch, and can host conversations related to the changes you want to make. Here, we want to merge from each of our branches into development. We want to merge the content from the branch on the right into the branch on the left (it’s like the assignment operator).

You want to make the following merges:

  • Backend Recipe Creation Bug <- Frontend Delete Recipe Bug
  • development <- Backend Recipe Creation Bug
  • development <- Backend MakeRecipe Bug

DO NOT use the Compare & pull request buttons for each of the branches if they are available. If you do, make sure that you check the destination - you don’t want to PR directly into main!

Instead, create a New pull request and identify the merges yourself. We’ll show this example.

Github will give you a quick summary of the pull request you’re about to make, and if everything looks OK, click the “Create pull request” button. At this point, you’ll have a new pull request that looks something like the following:

You can add in additional information to clarify the pull request. This is helpful so that others can review. At this point, you can also assign teammates to review your pull request. Click the “Create pull request” button.

This will create the Pull Request. Pull requests are numbered like issues. Issues and pull request numbers are interleaved. The pull request will (eventually) trigger GitHub Actions to build your project. You’ll get a reminder to wait for the build to finish before merging the PR once GitHub Actions are integrated into the project. Once the build is done, you’ll see the results.

Now, we can merge our pull request to copy our changes from the branch into the parent branch or the development branch. In general, you never want to merge your own pull requests. The point of creating them is to get someone else to review your code, so your team should take the time to look over what you have and decide if it should be merged as-is or needs changes. If you’re working on a team assignment, you should assign a teammate to review the pull request and merge into the appropriate branch. If you’re working on an individual assignment, you can merge your own pull requests.

If you find problems when reviewing a pull request, you can leave comments, add additional commits, or add comments to the changed code. Only merge a pull request that you have reviewed and agree makes forward progress on the code base!.

To merge, click “Merge pull request” and then “Confirm merge”.

DO NOT DELETE MERGED BRANCHES. We want to see your work!

Repeat this process for the other two branches you created to merge the fixes for all of the bugs together. At this point, you should have created and merged three pull requests into development with your fixes for each of the bugs from above.

If you included phrased like Fixed #1 in your commits, the Issues will be closed once you merge the branches via a pull request!

Update Local Repository

Now that we’ve combined everything together on the remote GitHub via pull requests, we need to ensure those changes are copied to our local repository. Pull all the changes to your local environment and checkout your development branch. You can run your automated and manual tests to ensure the changes are in your local code base.

Now, we want to test that everything is working properly when all of the bits have been combined together. From your local environment, run git pull. This will fetch the new development branch and the changes on it. Then, run git checkout development to switch to the new branch.

Terminate any existing builds of the project, if they haven’t crashed as part of the branch swap, and then re-launch as before. Run your system tests to make sure everything works.

Deliver via Pull Request to main

Now that you’ve verified that everything is passing, you can deliver your code to main for evaluation by the teaching staff. Do this through creating a pull request from development to main.

When creating the pull request, you can add the text that will close the issues associated with the pull request. This will close the issues when the pull request is merged!

Closing Issues

You can close issues when creating a PR between development and main by including strings like “close” or “fix” followed by the issue number. You can also close issues through the interface. Since we’ve verified the issues are resolved, we can close the issues! You should always close issues to show that the task is complete.

Putting It All Together

Today, we’ve taken our first steps into the process of developing software through the journey of debugging web applications. We’ve seen how there can bugs at any level of the system. We’ve also seen how to create high-quality bug reports that describe the issue we’re facing, and how to use debugging tools to uncover where in the code the bug lies. Next, we saw how to use git branching and pull requests to fix each bug independently, incorporate the changes back into our code base, and saw how our issues were closed auto-magically.

Update Your Tasks

Make sure that you completed all your tasks in your Tasks wiki page!

Activity: Independent Deliverables

So far, we’ve tracked down three bugs in the CoffeeMaker system, written bug reports for them, and then fixed them, all while following good software development process. However, there are still plenty of other bugs in the system. Your individual task is to identify two more bugs in the system and create bug reports for them via Github Issues. This time, we’re not telling you what the bugs are – you’ll need to test the system manually against the provided requirements. DO NOT fix the bugs. That will come later once you learn about the technologies used as part of the CoffeeMaker.

Strategies for Finding Bugs

There are several techniques for finding errors in your code. The most common is testing. We can create tests from the requirements using test generation strategies like equivalence classes, boundary values, and invalid path tests.

Another technique is to use static analysis to find potential problems. Review the static analysis output for Checkstyle or ESLint by either running locally or reviewing the results of GitHub actions. See the technical-documents/static-analysis.md page in your repo for more details.

If you review the static analysis notifications and the surrounding code, you may be able to identify paths that should be considered when testing. Then you can brainstorm the inputs to cause the failure!

Another strategy is to use AI to support exploration of the requirements and static analysis results.

Using AI to Explore

You may use an AI assistant to help you look for bugs. You may not use it to write your bug reports.

That split is deliberate, and it’s worth understanding why. An assistant is genuinely useful at the exploration step — it can read a requirement and a class side by side faster than you can, and suggest places they might disagree. What it cannot do is confirm that a bug is real. Every suggestion it gives you is a hypothesis, and roughly half of them will be wrong: behavior that looks like a defect but isn’t or it may not be a bug because of an ambiguity in the requirement. Writing the bug report is where you demonstrate that you reproduced the problem, isolated it, generalized it, and understood it well enough to describe it in your own words. That is the skill being assessed, so it stays yours.

Ground Rules

  • Reproduce before you report. If you cannot make the bug happen in the running system yourself, you do not have a bug — you have a guess.
  • Write the issue yourself. Steps to reproduce, isolate, and generalize are your words, based on what you observed. Do not paste an assistant’s description into an issue.
  • Never assume it read the code correctly. Assistants confidently describe methods that don’t exist and flow that isn’t there. Open the file and review the code.

If you decide not to use AI for this tasks, that’s fine. State that you didn’t use it. Instead, use the prompts to guide your review of the system. The strategies are useful for both humans and AI! Either way, you’ll reflect on your experience in the retrospective.

Starter Prompts

These are starting points, not a script. The most useful thing you can do is anchor the assistant to the requirements so it has something concrete to compare the code against — a prompt like “find bugs in this file” gets you generic style complaints, while a prompt that supplies the requirement gets you candidate mismatches.

Compare implementation against a requirement

Here is Use Case 2 (Add Recipe) from our requirements:
<paste the use case, including its alternative flows>

Here are the relevant classes: RecipeController, RecipeService, Recipe.

List every place the implementation appears NOT to match this requirement.
For each one, quote the specific requirement text and the specific line of
code, and tell me what you would do in the UI to observe the difference.

Asking it to name what you’d do in the UI is what makes the output testable — you get a reproduction step you can go run, rather than an assertion you’d have to take on faith.

Identify tests to exercise static analysis notifications

For the ESLint notification listed below, suggest a flow of events that would uncover the fault as a failure.

[Notification text here]

Not every static analysis notification will lead to a bug, but the more serious ones can. One way to learn more about static analysis notifications is to explore how you might write a test to run into the issue. AI can identify a set of steps that might lead to the failure that you can refine for creating a bug report. Note that the flow may not be executable to find the bug depending on the data in your database or it might be masked by other issues.

Hunt for unhandled alternative flows

This use case lists the following alternative flows:
<paste the alternative flows>

For each one, tell me whether the code appears to handle it, and which
method would be responsible. Point out any that appear unhandled.

Alternative flows are where CoffeeMaker’s remaining bugs might live, because the main flow is what gets exercised most often during development.

Generate boundary inputs to try

This endpoint accepts <describe the fields and their types>.
Give me a list of input values that would be worth trying, grouped into
equivalence classes, including boundary values and invalid inputs.
Do not write tests -- I just want the list of values to try by hand.

You’ve seen equivalence classes and boundary values in prior coursework. Determine if the suggested values are appropriate values for various equivalence classes and boundary values given the requirements.

Explain, then verify

Explain step by step what this method does, including what happens when
<field> is empty, zero, or negative.

Then go read the method and check whether the explanation was right. When it isn’t, you have often found either a bug or a misleading piece of code — both worth noting.

Record It

Whatever you try, note it in retros/retro-m0.md in your repository: what you asked, whether it pointed you at anything real, and how much of your time it saved or cost. Both answers are legitimate findings. If you didn’t use AI at all, say that and describe how the prompts helped or hindered your bug finding.