Skip to content

Conversation

@chawdamrunal
Copy link

Issue

The error handler in docs/pages/api/sign-cloudinary-params.js references an undefined variable e instead of the correctly scoped error variable, causing a ReferenceError when errors occur.

Bug Details

File: docs/pages/api/sign-cloudinary-params.js:16
Severity: Low
Type: Runtime Error

The catch block defines the error parameter as error, but the code references e.message:

} catch (error) {  // ✅ Parameter named 'error'
  res.status(500).json({
    error: e.message,  // ❌ References 'e' (undefined)
  });
}

Impact

  • When signature generation fails, the server throws an additional ReferenceError: e is not defined
  • Clients receive incomplete responses or timeouts instead of proper error messages
  • The original error is obscured, making debugging difficult

Fix

Changed e.message to error.message to match the catch parameter:

} catch (error) {
  res.status(500).json({
    error: error.message,  // ✅ Correct variable reference
  });
}

Testing

  • ✅ Code compiles without errors
  • ✅ Variable reference is now consistent
  • ✅ Error handler will work correctly when exceptions occur

Hacktoberfest 2025

This contribution is part of Hacktoberfest 2025.


Checklist:

  • Bug fix for undefined variable
  • Simple, focused change
  • Clear commit message

Fix ReferenceError caused by referencing undefined variable 'e' instead
of the correctly scoped 'error' variable in the catch block.

Before: catch (error) { ... e.message }
After:  catch (error) { ... error.message }

This bug prevented proper error responses when signature generation failed,
causing the error handler itself to throw an exception.

Hacktoberfest contribution
@vercel
Copy link

vercel bot commented Oct 8, 2025

Someone is attempting to deploy a commit to the Cloudinary DevX Team on Vercel.

A member of the Team first needs to authorize it.

@eportis-cloudinary
Copy link
Contributor

Thanks so much for catching the issue! Accepting.

@eportis-cloudinary eportis-cloudinary merged commit 148e037 into cloudinary-community:main Nov 6, 2025
1 check failed
@eportis-cloudinary
Copy link
Contributor

@all-contributors please add @chawdamrunal for code

@allcontributors
Copy link
Contributor

@eportis-cloudinary

I've put up a pull request to add @chawdamrunal! 🎉

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

🎉 This PR is included in version 6.17.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants