Skip to content

Conversation

@vnessamartinez
Copy link
Contributor

No description provided.

@vnessamartinez
Copy link
Contributor Author

The following error shows up when a column is blank in a row in a crosswalk file. It looks for an asset at the path in the column, but when the field is blank, it throws an error because it doesn't exist. For example, this repo has a crosswalk that has both png and jpg images, in that order. When the png field is blank because there is something in the jpg column instead, Baker throws the following error. This PR adds a check for it to first check that there is something in the field before looking for the path.
Screenshot 2025-03-26 at 9 55 05 AM

lib/index.js Outdated

preppedData.assets[normalizedAssetType][normalizedAssetName][ext] =
this.getStaticPath(path);
if (path && path.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

just check if (path), this will catch undefined, null, and empty strings. If there is no path we should show an error or warning. So code should look like:

if (!path) {
  console.error(`Could not find static path for asset :${normalizedAssetName} and path: ${path}`);
  return;
}

preppedData.assets[normalizedAssetType][normalizedAssetName][ext] = this.getStaticPath(path);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We implemented this suggestion and tweaked the error message. We made it into a warning instead because the error message being in red felt like it would be an error that would stop the build, but it's not.

        if (!path) {
          console.warn(
            `Could not find static path for asset: ${normalizedAssetName} with the extension: ${ext}. Skipping.`
          );
          return;
        }

Is there a way to maybe run npm start with both a quiet version and a --verbose version that prints out the warnings? If your crosswalk has a lot of different file types, the warnings can be a little overwhelming, and it may be useful to have an option to show only errors instead of warnings.

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.

4 participants