Skip to content

Add edit command to notes tool - #173

Open
Iter1993 wants to merge 7 commits into
mate-academy:mainfrom
Iter1993:review-me
Open

Add edit command to notes tool#173
Iter1993 wants to merge 7 commits into
mate-academy:mainfrom
Iter1993:review-me

Conversation

@Iter1993

@Iter1993 Iter1993 commented Sep 2, 2026

Copy link
Copy Markdown

Adds an edit <id> <text> command plus scaffolding (config, tests, CI, .gitignore). See review notes on the fork PR: Iter1993#1

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

The edit function in lib/store.js has a critical bug that needs fixing. When data.notes.find() returns undefined (because the note ID doesn't exist), line 51 attempts to set note.text = text, which throws a TypeError: Cannot set property 'text' of undefined. This crashes the application instead of gracefully handling the error. Unlike remove() which returns a boolean for success/failure, edit() has no null check and returns nothing, making it impossible for callers to distinguish success from failure. To fix this, add a null check after the find() call: if the note isn't found, return false (or throw a descriptive error), and return true on successful edit. Then update the edit case in notes.js to check this return value before printing the success message, so users get proper feedback when trying to edit a non-existent note.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread lib/store.js
Comment on lines +48 to +51
function edit(id, text) {
const data = load();
const note = data.notes.find((n) => n.id === id);
note.text = text;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug here: If no note has the given id, find() returns undefined. Then line 51 tries to set undefined.text, throwing a TypeError. Consider returning a boolean (like remove() does) or throwing a descriptive error, and handle it in notes.js.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants