Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start_column cannot be null #14

Closed
ataylorme opened this issue Dec 17, 2020 · 5 comments · Fixed by #17
Closed

start_column cannot be null #14

ataylorme opened this issue Dec 17, 2020 · 5 comments · Fixed by #17
Assignees
Labels
bug Something isn't working

Comments

@ataylorme
Copy link
Owner

Related to #7. A fix similar to #8 but for start_column should resolve this.

@ataylorme ataylorme added the bug Something isn't working label Dec 17, 2020
@ataylorme
Copy link
Owner Author

@ataylorme I'm now getting 'output.annotations[0].start_column' cannot be null in some areas...

https://github.com/google/web-stories-wp/pull/5572/checks?check_run_id=1500127987#step:8:9

@swissspidy can you upload an ESLint JSON file that has this issue? I will use it to make a unit test, then work on a fix.

@swissspidy
Copy link

@ataylorme sure! this should be it:

[{"filePath":"/path/to/src/edit-story/app/media/utils/useUploadVideoFrame.js","messages":[{"ruleId":"jsdoc/require-param-description","severity":1,"message":"Missing JSDoc @param \"url\" description.","line":104,"column":null,"nodeType":"Block","endLine":104,"endColumn":null},{"ruleId":"jsdoc/require-param-type","severity":1,"message":"Missing JSDoc @param \"url\" type.","line":104,"column":null,"nodeType":"Block","endLine":104,"endColumn":null},{"ruleId":"jsdoc/require-returns-description","severity":1,"message":"Missing JSDoc @return description.","line":105,"column":null,"nodeType":"Block","endLine":105,"endColumn":null}],"errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"/*\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * External dependencies\n */\nimport { useCallback } from 'react';\n/**\n * Internal dependencies\n */\nimport { useAPI } from '../../api';\nimport { useStory } from '../../story';\nimport { useConfig } from '../../config';\nimport { useUploader } from '../../uploader';\nimport { preloadImage, getFirstFrameOfVideo } from './';\n\nfunction useUploadVideoFrame({ updateMediaElement }) {\n  const {\n    actions: { updateMedia },\n  } = useAPI();\n  const { uploadFile } = useUploader();\n  const { storyId } = useConfig();\n  const { updateElementsByResourceId } = useStory((state) => ({\n    updateElementsByResourceId: state.actions.updateElementsByResourceId,\n  }));\n  const setProperties = useCallback(\n    (id, properties) => {\n      updateElementsByResourceId({ id, properties });\n    },\n    [updateElementsByResourceId]\n  );\n\n  const processData = async (id, src) => {\n    try {\n      const obj = await getFirstFrameOfVideo(src);\n      obj.name = getFileName(src) + '-poster.jpeg';\n      const {\n        id: posterId,\n        source_url: poster,\n        media_details: { width: posterWidth, height: posterHeight },\n      } = await uploadFile(obj);\n      // Meta data cannot be sent as part of upload.\n      await updateMedia(posterId, {\n        meta: {\n          web_stories_is_poster: true,\n        },\n      });\n      await updateMedia(id, {\n        featured_media: posterId,\n        meta: {\n          web_stories_poster_id: posterId,\n        },\n        post: storyId,\n      });\n\n      // Preload the full image in the browser to stop jumping around.\n      await preloadImage(poster);\n\n      // Overwrite the original video dimensions. The poster reupload has more\n      // accurate dimensions of the video that includes orientation changes.\n      const newSize =\n        (posterWidth &&\n          posterHeight && {\n            width: posterWidth,\n            height: posterHeight,\n          }) ||\n        null;\n      const newState = ({ resource }) => ({\n        resource: {\n          ...resource,\n          posterId,\n          poster,\n          ...newSize,\n        },\n      });\n      setProperties(id, newState);\n      updateMediaElement({\n        id,\n        posterId,\n        poster,\n        ...newSize,\n      });\n    } catch (err) {\n      // TODO Display error message to user as video poster upload has as failed.\n    }\n  };\n\n  /**\n   * Helper function get the file name from url.\n   *\n   * @param url\n   * @return {string}\n   */\n  const getFileName = (url) =>\n    url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));\n\n  /**\n   * Uploads the video's first frame as an attachment.\n   *\n   */\n  const uploadVideoFrame = useCallback(processData, [\n    storyId,\n    updateMediaElement,\n    uploadFile,\n    updateMedia,\n    setProperties,\n  ]);\n\n  return {\n    uploadVideoFrame,\n  };\n}\n\nexport default useUploadVideoFrame;\n","usedDeprecatedRules":[{"ruleId":"jsx-a11y/accessible-emoji","replacedBy":[]}]}]

ataylorme added a commit that referenced this issue Dec 19, 2020
@ataylorme ataylorme mentioned this issue Dec 19, 2020
@ataylorme
Copy link
Owner Author

@swissspidy can you test out the 1.1.3-beta1 branch in the workflow that is had issues? You can do this with - uses: ataylorme/eslint-annotate-action@1.1.3-beta1.

See https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#example-using-versioned-actions

@ataylorme ataylorme self-assigned this Dec 19, 2020
@swissspidy
Copy link

Running that locally seems to work fine 👍

swissspidy added a commit to GoogleForCreators/web-stories-wp that referenced this issue Apr 7, 2021
ataylorme added a commit that referenced this issue Apr 8, 2021
* Bump the version to `1.1.3`
* Add a `start_column` is not null check
* Update GitHub Actions to use the latest version

Closes #14
@ataylorme
Copy link
Owner Author

@swissspidy FYI this fix has been merged and version 1.1.3 has been released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants