slymnoyann/hey-1 · warning · Error
Add a valid video thumbnail before posting.
Error message
Add a valid video thumbnail before posting.
What it means
Thrown by getVideoDuration in usePostMetadata.tsx when building metadata for a video post: either no thumbnail URL is set, or videoDurationInSeconds can't be parsed into a finite positive number. Videos on Lens require a cover thumbnail and a duration, so metadata generation refuses to continue without both.
Source
Thrown at src/hooks/usePostMetadata.tsx:43
attachment: (typeof attachments)[number] | undefined
) => {
if (!attachment?.uri || !attachment.mimeType) {
throw new Error("Please wait for attachments to finish uploading.");
}
return { ...attachment, uri: attachment.uri };
};
const formatAttachments = () =>
attachments.slice(1).map((attachment) => ({
item: assertUploadedAttachment(attachment).uri,
type: attachment.mimeType
}));
const getVideoDuration = () => {
const duration = Number.parseFloat(videoDurationInSeconds);
if (!videoThumbnail.url || !Number.isFinite(duration) || duration <= 0) {
throw new Error("Add a valid video thumbnail before posting.");
}
return duration;
};
const getMetadata = useCallback(
({ baseMetadata }: UsePostMetadataProps) => {
const primaryAttachment = attachments[0];
const hasAttachments = Boolean(primaryAttachment);
const isImage = primaryAttachment?.type === "Image";
const isAudio = primaryAttachment?.type === "Audio";
const isVideo = primaryAttachment?.type === "Video";
if (!hasAttachments) {
return baseMetadata.content?.length > 2000
? article(baseMetadata)
: textOnly(baseMetadata);
}View on GitHub (pinned to 88c8f9d553)
Solutions
- Require thumbnail selection before enabling publish for video posts
- Read duration only from the loadedmetadata event and guard Number.isFinite(duration) && duration > 0 at capture time, storing 0 as invalid
- If thumbnail upload failed, retry it and keep the composer in 'not ready' state until videoThumbnail.url is truthy
- Catch this error and surface a specific message pointing to the missing thumbnail vs invalid duration
Example fix
// before
const duration = Number.parseFloat(videoDurationInSeconds);
if (!videoThumbnail.url || !Number.isFinite(duration) || duration <= 0) {
throw new Error("Add a valid video thumbnail before posting.");
}
// after: split the two failure modes for clearer UX
if (!videoThumbnail.url) {
throw new Error("Add a video thumbnail before posting.");
}
const duration = Number.parseFloat(videoDurationInSeconds);
if (!Number.isFinite(duration) || duration <= 0) {
throw new Error("Could not read video duration; re-select the video file.");
} Defensive patterns
Strategy: validation
Validate before calling
const hasVideoRequirements = Boolean(
videoThumbnail.url &&
Number.isFinite(Number.parseFloat(videoDurationInSeconds)) &&
Number.parseFloat(videoDurationInSeconds) > 0
);
if (isVideoPost && !hasVideoRequirements) {
// keep publish disabled; highlight the thumbnail picker
} Type guard
const hasValidVideoMeta = (thumb: { url?: string }, duration: string): boolean =>
Boolean(thumb.url) && Number.isFinite(Number.parseFloat(duration)) && Number.parseFloat(duration) > 0; Try / catch
try {
const duration = getVideoDuration();
} catch (e) {
if (e instanceof Error && e.message.includes("video thumbnail")) {
// route the user to the thumbnail selection step
}
} Prevention
- Capture duration from the loadedmetadata event and treat NaN/0 as invalid immediately
- Require a thumbnail (default to first generated frame) before publish is enabled
- Verify thumbnail IPFS upload succeeded before allowing the video post flow to continue
When it happens
Trigger: Publishing a video without choosing a thumbnail (videoThumbnail.url empty), a duration string like ''/'NaN'/'0s' fed into Number.parseFloat, or the video element's duration being NaN/Infinity because metadata never loaded or the file is a live/unsupported stream.
Common situations: User skips the thumbnail step; thumbnail upload to IPFS failed so decentralizedUrl never populated; duration read before onloadedmetadata fired; seekbar-based duration measurement returning 0 for very short clips.
Related errors
AI-assisted analysis of slymnoyann/hey-1@88c8f9d553 (2026-08-28).
Data as JSON: /api/errors/4b05c6b97cc2d746.
Report an issue: GitHub.