Skip to content

[Due for payment 2025-11-10] [$250] Chat - Message has over 15k characters error is shown after sending the message #71995

Closed

Description

@jponikarchuk

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: Vo.2.24-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: https://test-management.browserstack.com/projects/2219752/test-runs/TR-1162/folder/13176681/41236983/936935226
Email or phone of affected tester (no customers): Slottwo1 mployee@gmail.com
Issue reported by: Applause Internal Team
Device used: Redminote 10s android 13 phone
App Component: Chat Report View

Action Performed:

  1. Launch app
  2. Open a chat
  3. Paste the message - 6 or 7 times [use error message text]
  4. Send the message
  5. Note Compose box remains expanded few seconds
  6. Scroll the message

Text:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce sem eros, euismod eu purus quis, feugiat ultricies augue. Fusce scelerisque urna eu felis maximus vestibulum. Proin cursus dictum ipsum sit amet tincidunt. Mauris consectetur condimentum urna ac dictum. Pellentesque viverra enim ut lacus faucibus, id aliquet leo vestibulum. Maecenas tortor orci, dictum at sagittis congue, volutpat ac libero. Maecenas vel rhoncus justo, in finibus nunc. Maecenas sed maximus felis. Nulla lobortis faucibus augue, vitae gravida orci faucibus in. Sed risus augue, malesuada eget porta in, rhoncus sed neque. Integer nibh ex, interdum ut molestie ac, placerat ut tortor. Morbi quis metus quis metus venenatis vehicula ac nec massa. Duis sapien ipsum, euismod sit amet finibus blandit, porttitor lacinia ipsum. Duis convallis mauris risus, in faucibus mi tempus et. Ut ac eros non purus volutpat blandit quis vel ipsum. Vivamus porttitor malesuada imperdiet.
Donec tortor ipsum, pulvinar a posuere sed, rhoncus vitae nisl. Integer lobortis, sem eu ultricies porttitor, enim elit dapibus lacus, a mollis eros diam vitae elit. Sed fermentum facilisis velit, ac consectetur orci efficitur ac. Proin tincidunt nibh nec tellus porttitor, et lacinia nunc viverra. Maecenas porta maximus elit id pharetra. Vivamus scelerisque ante eget metus sollicitudin sagittis. Nulla eget finibus lacus. Suspendisse interdum rhoncus libero in tincidunt. Ut accumsan magna at urna accumsan pulvinar. Vivamus eget nibh iaculis, convallis erat in, vulputate risus. Nullam lobortis, risus eget consectetur semper, dolor libero pretium mi, eu varius libero sapien non odio. Nam laoreet dapibus velit eget interdum.
Maecenas sagittis feugiat sapien, sit amet dapibus dui aliquam a. Donec volutpat ornare augue in pulvinar. Donec sagittis nibh sed ipsum vestibulum consectetur. Vestibulum feugiat, augue eu volutpat gravida, eros felis vulputate nibh, vitae pellentesque felis turpis at nisl. Aenean tempor enim non laoreet iaculis. Maecenas elit ligula, porta id quam a, dapibus viverra urna. Ut in sem in metus eleifend dignissim a non quam. Phasellus in rhoncus massa, ut dictum erat. Cras viverra elit orci, sit amet vestibulum magna condimentum lobortis. Ut vitae libero convallis, commodo mauris sed, suscipit nisi. Morbi vel nibh molestie, ultrices enim quis, dictum orci. Morbi consectetur consequat lacus vel vulputate. Etiam rutrum condimentum elit, vel sollicitudin ante feugiat in.
Nullam egestas velit tortor, sit amet suscipit lacus porta ac. Curabitur feugiat risus quis nulla tempus, non vulputate libero facilisis. Sed eu viverra elit. Etiam massa enim, aliquam in consequat et, eleifend sit amet odio. Aenean pellentesque, dui varius tincidunt malesuada, nunc diam lobortis velit, et vestibulum ex dolor sodales ipsum. Nam at elementum lectus. Nulla nisl ipsum, gravida eu dictum vitae, rhoncus id arcu. Suspendisse ut neque leo.

Expected Result:

User must not be allowed to send more than 15k.

Actual Result:

Message has over 15k characters error is shown after sending the message.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

11.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021975585816698117729
  • Upwork Job ID: 1975585816698117729
  • Last Price Increase: 2025-10-14
  • Automatic offers:
    • andriivitiv | Contributor | 109152279

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 7, 2025
  2. melvin-bot commented on Oct 7, 2025

    @melvin-bot

    Triggered auto assignment to @clarajones-expensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. andriivitiv commented on Oct 7, 2025

    @andriivitiv
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    It should not be possible to send a message exceeding 15,000 characters.

    What is the root cause of that problem?

    The message length validation is wrapped in lodashDebounce with a 1.5-second delay. If a user quickly pastes and sends a message, the debounce may not have executed yet, allowing oversized messages to bypass the validation.

    const debouncedValidate = useMemo(() => lodashDebounce(validateMaxLength, CONST.TIMING.COMMENT_LENGTH_DEBOUNCE_TIME, {leading: true}), [validateMaxLength]);
    const onValueChange = useCallback(
    (value: string) => {
    if (value.length === 0 && isComposerFullSize) {
    setIsComposerFullSize(reportID, false);
    }
    debouncedValidate(value);
    },
    [isComposerFullSize, reportID, debouncedValidate],
    );

    What changes do you think we should make in order to solve the problem?

    We need to validate the message right before sending it.

    First, return validation results from validateCommentMaxLength and validateTaskTitleMaxLength (true if the message is valid, otherwise false). Then return the result of these functions from validateMaxLength here.

    Next, pass the debouncedValidate.flush function to composerRefShared

    composerRefShared.set({
    clear: ref?.clear,
    });

    composerRefShared.set({
        clear: ref?.clear,
        validate: debouncedValidate.flush,
    });

    Finally, check if the message is valid right before sending it

    const handleSendMessage = useCallback(() => {
    'worklet';
    const clearComposer = composerRefShared.get().clear;
    if (!clearComposer) {
    throw new Error('The composerRefShared.clear function is not set yet. This should never happen, and indicates a developer error.');
    }
    if (isSendDisabled) {
    return;
    }
    // This will cause onCleared to be triggered where we actually send the message
    clearComposer();
    }, [isSendDisabled, composerRefShared]);

    const validate = composerRefShared.get().validate;
    if (!validate?.()) {
        return;
    }

    If there is a pending invocation of the debounced function, debouncedValidate.flush() will invoke it immediately and return its return value. Otherwise, it will return the value from the last invocation.

    We will also need to apply a similar fix to ReportActionItemMessageEdit.

  4. changed the title [-]Chat - Message has over 15k characters error is shown after sending the message[/-] [+][$250] Chat - Message has over 15k characters error is shown after sending the message[/+] on Oct 7, 2025
  5. melvin-bot commented on Oct 7, 2025

    @melvin-bot
  6. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 7, 2025
  7. melvin-bot commented on Oct 7, 2025

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @hoangzinh (External)

  8. zainAwan9175 commented on Oct 11, 2025

    @zainAwan9175
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On Android, users can send messages exceeding the 15,000 character limit.

    What is the root cause of that problem?

    The root cause is a race condition between validation timing and the send action:
    When users paste long text, the validateCommentMaxLength function is debounced with a 1500ms delay.

    const validateCommentMaxLength = useCallback(
    (value: string, parsingDetails?: ParsingDetails) => {
    if (ReportUtils.getCommentLength(value, parsingDetails) <= CONST.MAX_COMMENT_LENGTH) {

    The SendButton uses a GestureDetector
    const Tap = Gesture.Tap().onEnd(() => {
    handleSendMessage();

    On Android, the GestureDetector processes taps immediately at the native level (within 100-300ms after paste),while the debounced validation hasn't completed yet.
    When the user taps Send isSendDisabled is still false because the validation state hasn't updated yet.
    const isSendDisabled = isCommentEmpty || isBlockedFromConcierge || !!exceededMaxLength;

    The handleSendMessage function only checks isSendDisabled state, but doesn't validate the actual comment length at send time.

    const handleSendMessage = useCallback(() => {
    'worklet';
    const clearComposer = composerRefShared.get().clear;
    if (!clearComposer) {
    throw new Error('The composerRefShared.clear function is not set yet. This should never happen, and indicates a developer error.');
    }
    if (isSendDisabled) {
    return;
    }
    // This will cause onCleared to be triggered where we actually send the message
    clearComposer();
    }, [isSendDisabled, composerRefShared]);

    This issue is Android-specific because, on Android, the GestureDetector from react-native-gesture-handler processes taps immediately at the native level, before React state updates can complete.
    On the web, clicks go through the browser's event system, which gives React more time to process state updates.

    What changes do you think we should make in order to solve the problem?

    Add synchronous validation in the handleSendMessage function to check the actual comment length before sending, similar to how the edit message flow

    
        if (isSendDisabled) {
            return;
        }
        // Synchronous validation: Check actual comment length before sending
        // This prevents the race condition where users tap send before debounced validation completes
        const currentComment = getDraftComment(reportID) ?? '';
        const commentLength = getCommentLength(currentComment, {reportID});
        
        if (commentLength > CONST.MAX_COMMENT_LENGTH) {
            // Update validation state to show error to user
            runOnJS(setHasExceededMaxCommentLength)(true);
            runOnJS(setExceededMaxLength)(CONST.MAX_COMMENT_LENGTH);
            return;
        }
    

    Key points:
    Uses getDraftComment() to get the current text (works in worklet context)
    Uses getCommentLength() the same function the backend uses for validation
    Uses runOnJS() to safely update React state from the worklet
    Returns early if validation fails, preventing the message from being sent

    Result:

    WhatsApp.Video.2025-10-12.at.3.42.24.AM.mp4

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    Paste long text (>15k chars) and tap Send
    Expected: Message is not sent, error message appears, red border shows

    What alternative solutions did you explore?

    n/A

  9. melvin-bot commented on Oct 14, 2025

    @melvin-bot

    📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

  10. melvin-bot commented on Oct 15, 2025

    @melvin-bot

    @hoangzinh Still overdue 6 days?! Let's take care of this!

  11. 7 remaining items

  12. melvin-bot commented on Oct 17, 2025

    @melvin-bot

    📣 @andriivitiv 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

    Offer link
    Upwork job
    Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
    Keep in mind: Code of Conduct | Contributing 📖

  13. hoangzinh commented on Nov 4, 2025

    @hoangzinh
    Contributor

    It looks like automation was broken. The PR has been deployed to Prod early morning #72917 (comment)

  14. changed the title [-][$250] Chat - Message has over 15k characters error is shown after sending the message[/-] [+][Due for payment 2025-11-04] [$250] Chat - Message has over 15k characters error is shown after sending the message[/+] on Nov 4, 2025
  15. changed the title [-][Due for payment 2025-11-04] [$250] Chat - Message has over 15k characters error is shown after sending the message[/-] [+][Due for payment 2025-11-10] [$250] Chat - Message has over 15k characters error is shown after sending the message[/+] on Nov 4, 2025
  16. clarajones-expensify commented on Nov 13, 2025

    @clarajones-expensify
    Contributor

    Payment Summary

    Contributor: @andriivitiv paid $250 via Upwork
    Contributor+: @hoangzinh due $250 via NewDot

  17. hoangzinh commented on Nov 14, 2025

    @hoangzinh
    Contributor

    Thanks @clarajones-expensify. I requested in ND

  18. twisterdotcom commented on Nov 15, 2025

    @twisterdotcom
    Contributor

    @hoangzinh has submitted payment for this report on ND here.

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

    Zapier Logs Run ID: 00040eee-913e-a7c5-8172-19eda354deb1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in review

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions