Skip to content

Can't find bundle for base name i18n.Validation, locale en_IN #3035

Closed

Description

@khilendra

before we were using graphq-java:15.0 but this version showing one crital vulnerability and suggested to updrade 19.0 and later.
After updating 19.2. Our plugin api calls not working and throwing error

{
  "errors": [
    {
      "errorClassification": "DataFetchingException",
      "cause": {
        "className": "i18n.Validation_en_IN",
        "key": "",
        "detailMessage": "Can't find bundle for base name i18n.Validation, locale en_IN",
        "stackTrace": [],
        "suppressedExceptions": []
      },
      "stackTrace": [],
      "suppressedExceptions": []
    }
  ]
}

Any once can help me

Activity

  1. dondonz commented on Nov 30, 2022

    @dondonz
    Member

    Hello, thanks for raising the issue! That's a bug and we'll fix it

    It's a problem with not handling the region IN

  2. khilendra commented on Nov 30, 2022

    @khilendra
    Author

    ok so what can I do for now.
    I want to run my application with using 19.0+

  3. bbakerman commented on Nov 30, 2022

    @bbakerman
    Member

    Donna might have jumped the gun here sayings its a know bug.

    I have created a PR showing that resource bundle lookup works as expected

    #3036

    but we are not i18n super experts so perhaps there is a situation we are not aware of - for example some defaulting on a computer running in India for example?? Or some other overriding in place some how

    but the ResourceBundle lookup is working as we would expected given the tests in that PR

  4. khilendra commented on Nov 30, 2022

    @khilendra
    Author

    But I have also tried with US timezone and same error give me

    {
      "errors": [
        {
          "errorClassification": "DataFetchingException",
          "cause": {
            "className": "i18n.Validation_en_US",
            "key": "",
            "detailMessage": "Can't find bundle for base name i18n.Validation, locale en_US"
         }
    ]
    }
    
  5. khilendra commented on Nov 30, 2022

    @khilendra
    Author

    bbakerman

    I do not want to use i18n feature when executing query so how can ignore or disable?

  6. bbakerman commented on Nov 30, 2022

    @bbakerman
    Member

    But I have also tried with US timezone and same error give me

    Can you please tell us more about how you "tried with US timezone"

    What this passing in a new Locale to the ExecutionInput or was this a JVM defaulting to Locale?

    We don't have a way to disable Localisation - its an intended feature and works as far as we can see this end so being able to reproduce the bug is essential to getting a fix

    What JVM are you running, what version? What environment are you running this in?

    Can you write a simple reproduction program to show this happening?

    We will need more reproduction details to help here

  7. khilendra commented on Dec 1, 2022

    @khilendra
    Author

    This is my code base for execution

    
       ExecutionResult executionResult;
            try {
                JsonReader jsonReader = new JsonReader(req.getReader());
                Map<String, Object> requestBody = new Gson().fromJson(jsonReader, Map.class);
                ExecutionInput executionInput = ExecutionInput.newExecutionInput()
                        .query((String) requestBody.get("query"))
                        .variables(Optional.ofNullable((Map) requestBody.get("variables")).orElse(Collections.emptyMap()))
                        .locale(new Locale("en", "US"))
                        .build();
                executionResult = graphQL.execute(executionInput);
    
            } catch (Exception e) {
                log.error("log :", e);
                executionResult = ExecutionResultImpl.newExecutionResult()
                        .addError(GraphqlErrorException.newErrorException().cause(e).build())
                        .build();
            }
            this.sendAsJson(resp, executionResult);
    

    My Default Locale Country code is "es_IN" but I have changed using by locale(new Locale("en", "US")).

    I'm using java version
    java 11.0.16.1 2022-08-18 LTS
    Java(TM) SE Runtime Environment 18.9 (build 11.0.16.1+1-LTS-1)
    Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.16.1+1-LTS-1, mixed mode)

  8. bbakerman commented on Dec 1, 2022

    @bbakerman
    Member

    Can you please try to run this code on your system with graphql-java 19.2 on the class path

    package org.example;
    
    import java.util.Locale;
    import java.util.ResourceBundle;
    
    public class Main {
        public static void main(String[] args) {
    
            Locale.setDefault(new Locale("en", "IN"));
    
            ResourceBundle defaultBundle = getBundle("i18n.Validation", Locale.getDefault());
            printInfo("defaultBundle", defaultBundle);
    
            ResourceBundle englishBundle = getBundle("i18n.Validation", Locale.ENGLISH);
            printInfo("englishBundle", englishBundle);
    
            ResourceBundle germanBundle = getBundle("i18n.Validation", Locale.GERMAN);
            printInfo("germanBundle", germanBundle);
    
            ResourceBundle indianBundle = getBundle("i18n.Validation", new Locale("en", "IN"));
            printInfo("indianBundle", indianBundle);
    
            ResourceBundle noBundle = getBundle("i18n.ValidationXXX", new Locale("en", "IN"));
            printInfo("noBundle", noBundle);
        }
    
        private static ResourceBundle getBundle(String baseName, Locale Default) {
            try {
                return ResourceBundle.getBundle(baseName, Default);
            } catch (Exception e) {
                e.printStackTrace(System.out);
                return null;
            }
        }
    
    
        private static void printInfo(String name, ResourceBundle bundle) {
            if (bundle!= null) {
                System.out.printf("%s = %s - %d keys\n", name, bundle, bundle.keySet().size());
            } else {
                System.out.printf("%s = null\n", name);
            }
        }
    }
    

    When I run this on my system (with 19.2 graphql -java on the class path) I get

    defaultBundle = java.util.PropertyResourceBundle@2626b418 - 51 keys
    englishBundle = java.util.PropertyResourceBundle@2626b418 - 51 keys
    germanBundle = java.util.PropertyResourceBundle@2626b418 - 51 keys
    indianBundle = java.util.PropertyResourceBundle@2626b418 - 51 keys
    java.util.MissingResourceException: Can't find bundle for base name i18n.ValidationXXX, locale en_IN
    	at java.base/java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:2045)
    	at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1683)
    	at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1586)
    	at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1549)
    	at java.base/java.util.ResourceBundle.getBundle(ResourceBundle.java:932)
    	at org.example.Main.getBundle(Main.java:26)
    	at org.example.Main.main(Main.java:20)
    noBundle = null
    

    Can you inspect your graphql-java 19.2 jar and check there is a set of files

    i18n\
       Execution.properties
       General.properties
       Validation.properties
    

    These are the fallback property files that should be used during ResourceBundle.getBundle()

    I used this gradle file say ( a simple IDEA generated one)

    plugins {
        id 'java'
    }
    
    group 'org.example'
    version '1.0-SNAPSHOT'
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        implementation 'com.graphql-java:graphql-java:19.2'
        testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
        testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
    }
    
    test {
        useJUnitPlatform()
    }
    

    I can't reproduce this - even if I set my Java locale to be en_IN on the command line or inside the program.

    I am starting to think this must be something unique on your system. Because 19.x has been out for a while and lots of international (and Indian) developers are using it.

  9. khilendra commented on Dec 1, 2022

    @khilendra
    Author

    @bbakerman Thanks for the brief details.

    I have run your code with simple java and its running perfectly as you mention expected result, I'm also getting.

    Also checked you library and here i18n/Validation.properties file exists

    I'm creating jira-data-center plugin and my all code running under the jira platform.
    so may be this issue is coming from atlassian environment side.

    I will contact with atlassain teams.

    Again thanks you for quick reply.

  10. bbakerman commented on Dec 1, 2022

    @bbakerman
    Member

    I'm creating jira-data-center plugin and my all code running under the jira platform.

    I do know a little about this - I worked on the Jira server platform about 6 years ago and still work for Atlassian. Jira Server uses OSGI for its plugin system. OSGI is at its heart a fancy class loader system and it sounds like you have some sort of class loading issue. And to confuse things it calls its modules "bundles" and we are having a "resource bundle" problem in a "osgi bundle".

    For example your graphql code is probably being called in the context of another OSGi plugin (or the master monolith bundle 0) and some how your OSGi bundle is not exporting access to these resources some how?? But I dont know off hand.

    Are your bundling graphql-java 19.2 as jar inside your plugin (osgi bundle) or are you trying to run graphql-java as a OSI bundle itself. Because I am not sure the latter works but I haven't tried it (I left OSGi land 4 years ago)

  11. bbakerman commented on Dec 2, 2022

    @bbakerman
    Member

    I have raised #3038 and hope to get a 19.3 out to see if this help you

    I had one of the OSGI gurus in Atlassian try my test program above inside a jira plugin and it all worked as expected and hence there must be something else going on in how you package your plugin code perhaps

  12. bbakerman commented on Dec 2, 2022

    @bbakerman
    Member

    graphql-java 19.3 has been released with the "class loader" used during resource loading - can you try that version and see if it helps you

  13. khilendra commented on Dec 2, 2022

    @khilendra
    Author

    @bbakerman

    I have upgrade the version 19.3 and tried but result is same error.
    I also tired with add custom properties file and call. Its working but when move this file under any folder like i18n and call then same error getting.

    so I think jira not allow call resource file with "."
    mean basename "i18n.validation" not support and throw error but when only call "validation" that is ok.

  14. khilendra commented on Dec 3, 2022

    @khilendra
    Author

    @bbakerman

    Can you confirm me graphql-java 17.4 is fixed below vulnerability
    "graphql-java before19.0 is vulnerable to Denial of Service. An attacker can send a malicious GraphQL query that consumes CPU resources. The fixed versions are 19.0 and later, 18.3, and 17.4, and 0.0.0-2022-07-26T05-45-04-226aabd9."

  15. dondonz commented on Dec 4, 2022

    @dondonz
    Member

    Hi @khilendra yes, graphql-java v17.4 contains the fix for the CVE.

    You can reference the official CVE text: https://www.cve.org/CVERecord?id=CVE-2022-37734

    PR with the fix for 17.4: #2902

  16. dondonz commented on Dec 4, 2022

    @dondonz
    Member
  17. khilendra commented on Dec 4, 2022

    @khilendra
    Author

    And our release note: https://github.com/graphql-java/graphql-java/releases/tag/v17.4

    Ok Thanks for reply and confirmation. So I'm going with 17.4 and its working with perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions