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

Error on Raygun.cfc Line 260: "java.lang.UnsupportedOperationException" when using contentFilter #58

Closed
gedas20 opened this issue Dec 19, 2023 · 5 comments

Comments

@gedas20
Copy link

gedas20 commented Dec 19, 2023

Using ColdFusion 2018.

When attempting to use the contentFilter parameter in the RaygunClient.cfc component, an error occurs on line 260, throwing a "java.lang.UnsupportedOperationException." The issue arises when the key specified in matcher.filter doesn't exist in element.owner.

Steps to Reproduce:
Instantiate the RaygunClient with a contentFilter containing a filter-replacement pair.
Trigger an error, such as sending an exception to Raygun using raygun.send().

Expected Behavior:
The structFindKey function should return an empty array if the specified key is not found in arguments.messageData.
Actual Behavior:
structFindKey returns an array with a struct even if the key is not present, leading to an "UnsupportedOperationException" on line 260.

If arguments.messageData is duplicated before the structFindKey call (e.g., arguments.messageData = duplicate(arguments.messageData);), the issue does not occur.

@gedas20
Copy link
Author

gedas20 commented Dec 19, 2023

Another way that fixes the issue is wrapping return on RaygunClient.cfc line 168, with duplcate():

messageContent = duplicate( message.build( duplicate( issueData ) ) );

@TheRealAgentK
Copy link
Contributor

TheRealAgentK commented Dec 21, 2023

@gedas20 I can't reproduce this issue:

Say, I have

raygun = createObject("component","nz.co.ventego-creative.raygun4cfml.RaygunClient").init(
    apiKey = "<APIKEY>",
    contentFilter = createObject(
        "component",
        "nz.co.ventego-creative.raygun4cfml.RaygunContentFilter").init( [
            {
                        filter      : "ghjdfkgdt",
                        replacement : "__hjkjkpassword__"
            }
        ] )
);

try {
        (1/0);
    } catch(any e) {
        result = raygun.send(e);
    }

I know that ghjdfkgdt is not in the payload, and consequently

var findKeysByFilter = structFindKey(arguments.messageData,matcher.filter); is an empty array.

Tried with ACF@2018, ACF@2021, Lucee 5.4

@gedas20
Copy link
Author

gedas20 commented Dec 21, 2023

This is interesting, after applying the fix for #57, i tried to reproduce #58 again, and same as you i could not reproduce it. So i figured maybe the #57 fix has something to do with this, cause the messageData goes trough nultiple cfc as it gets build.
So i did revert fix #57, and i started getting the issue again. So i think fix #57 fixes both of these issues. Cause is see use use duplicate(form), duplicate(cgi) and this probably addresses one of these structures that need to be duplicated for StructFindKey to work properly.

So try reverting #57 and see if you can reproduce this bug.

@TheRealAgentK
Copy link
Contributor

Yeah, ok - I see what that issue is now. This happens if there's not at least a duplicate(CGI) when returnContent["data"] is assigned in RaygunRequestMessage and because that's all been part of previous fixes since 1.6.0, it didn't happen anymore.

Just another really weird behaviour from ACF - it seems that structFindKey just thinks it finds the filter field name in the CGI scope, but it's not there. It shows once again that the ACF scopes are interesting creatures. When output, they look like a struct, but they are really not and cause all sorts of complications.

@TheRealAgentK
Copy link
Contributor

Solved via previous fixes for #56 and #57 and working in 1.7.0. Closing ticket.

TheRealAgentK added a commit to TheRealAgentK/raygun4cfml that referenced this issue Nov 15, 2024
TheRealAgentK added a commit that referenced this issue Nov 15, 2024
)

* Fixes 2 issues found when using RG4CFML in a new project (#3)

* Fixing some small issues

* Setting version to 1.7.0-SNAPSHOT

* Feature/#56 java memory management (#4)

* Documenting the issue from the OP in the ticekt.

* Wrapping access to getMemoryXBean into try/catch.

* Test scenario and fix. (#5)

* Changed supported versions of ACF/Lucee

* fix: applyFilter deep search (#6)

* Fixes core problem in #62.

* Testcase

* Prep for 1.7.0 release

* Test for GH #58

* Documentation/Changelog updates
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

No branches or pull requests

2 participants