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

Java: Display a clearer message when properties files is not found #2093

Closed
agoncal opened this issue Jul 20, 2023 · 1 comment
Closed

Java: Display a clearer message when properties files is not found #2093

agoncal opened this issue Jul 20, 2023 · 1 comment
Labels
java Issue or PR regarding Java code sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community)

Comments

@agoncal
Copy link
Member

agoncal commented Jul 20, 2023

To get the settings from a properties file, you use the following code

AzureOpenAISettings settings = AIProviderSettings.getAzureOpenAISettingsFromFile("conf.properties");

If something goes wrong the following message is displayed:

java.io.IOException: conf.properties not configured properly

Because the code swallows the exception, I had to debug the code of ClientSettings to see that the property file was not found (java.io.FileNotFoundException: /agoncal/agoncal-sample-semantic-kernel/conf.properties (No such file or directory)):

    protected String getSettingsValueFromFile(
            String settingsFile, String property, String clientSettingsId) throws IOException {
        File Settings = new File(settingsFile);

        try (FileInputStream fis = new FileInputStream(Settings.getAbsolutePath())) {
            Properties props = new Properties();
            props.load(fis);

            return props.getProperty(getPropertyNameForClientId(clientSettingsId, property));
        } catch (IOException e) {
            throw new IOException(settingsFile + " not configured properly");
        }
    }

It would be clearer, either if you display the exception message, or if you handle FileNotFoundException :

       // Display exception message
        } catch (IOException e) {
            throw new IOException(settingsFile + " not configured properly:" + e.getMessage());
        }

       // Handle FileNotFoundException
        } catch (FileNotFoundException e) {
            throw new FileNotFoundException(settingsFile + " not found");
        } catch (IOException e) {
            throw new IOException(settingsFile + " not configured properly");
        }
@shawncal shawncal added java Issue or PR regarding Java code triage labels Jul 20, 2023
dsgrieve pushed a commit that referenced this issue Jul 31, 2023
Move much of the logic of OpenAI config loading from samples to
connectors

Fixes #2093
@evchaki evchaki added sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community) and removed triage labels Aug 1, 2023
@brunoborges
Copy link
Member

Fixed by #2215

@agoncal we changed how settings are done. Let us know if this is still an issue, and if is, please reopen.

johnoliver added a commit to johnoliver/semantic-kernel that referenced this issue Jun 5, 2024
…oft#2115)

Move much of the logic of OpenAI config loading from samples to
connectors

Fixes microsoft#2093
johnoliver added a commit to johnoliver/semantic-kernel that referenced this issue Jun 5, 2024
…oft#2115)

Move much of the logic of OpenAI config loading from samples to
connectors

Fixes microsoft#2093
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java Issue or PR regarding Java code sk team issue A tag to denote issues that where created by the Semantic Kernel team (i.e., not the community)
Projects
No open projects
Status: Sprint: Done
Development

No branches or pull requests

4 participants