MinIO .Net client API failing with bogus General Exception - minio

MinIO is returning a general exception when calling the API from a .net client. In the library parsing the xml fails telling me that "Client calls PutObjectAsync General Exception 'doctype' is an unexpected token. The expected token is 'DOCTYPE'" which is no help at all.
MinIO Version
2021-09-09T21:37:07Z
Uploading objects using the webconsole works as expected.

Can you share an example of the code you are using? Please make sure you are using the S3 endpoint (running on port 9000 by default) and not the console-ui endpoint (9090 by default).
Here is a simple example of how to use the .net library to connect to the MinIO running on https://play.min.io:9000.
using Minio;
// Initialize the client with access credentials.
private static MinioClient minio = new MinioClient("play.min.io",
"Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
).WithSSL();
// Create an async task for listing buckets.
var getListBucketsTask = minio.ListBucketsAsync();
// Iterate over the list of buckets.
foreach (Bucket bucket in getListBucketsTask.Result.Buckets)
{
Console.WriteLine(bucket.Name + " " + bucket.CreationDateDateTime);
}
Please read more at https://docs.min.io/docs/dotnet-client-quickstart-guide.html

Related

GraphQL requesting fields that don't exist without error

I'm trying to handle backwards compatibility with my GraphQL API.
We have on-premise servers that get periodically updated based off of when they connect to the internet. We have a Mobile app that talks to the on-premise server.
Problem
We get into an issue where the Mobile app is up to date and the on-premise server isn't. When a change in the Schema occurs, it causes issues.
Example
Product version 1
type Product {
name: String
}
Product version 2
type Product {
name: String
account: String
}
New version of mobile app asks for:
product(id: "12345") {
name
account
}
Because account is not valid in version 1, I get the error:
"Cannot query field \"account\" on type \"Product\"."
Does anyone know how I can avoid this issue so I don't recieve this particular error. I'm totally fine with account coming back with Null or just some other plan of attack for updating Schema's. But having it completely blow up with no response is not good
Your question did not specify what you're actually using on the backend. But it should be possible to customize the validation rules a GraphQL service uses in any implementation based on the JavaScript reference implementation. Here's how you do it in GraphQL.js:
const { execute, parse, specifiedRules, validate } = require('graphql')
const validationRules = specifiedRules.filter(rule => rule.name !== 'FieldsOnCorrectType')
const document = parse(someQuery)
const errors = validate(schema, document, validationRules)
const data = await execute({ schema, document })
By omitting the FieldsOnCorrectType rule, you won't get any errors and unrecognized fields will simply be left off the response.
But you really shouldn't do that.
Modifying the validation rules will result in spec-breaking changes to your server, which can cause issues with client libraries and other tools you use.
This issue really boils down to your deployment process. You should not push new versions of the client that depend on a newer version of the server API until that version is deployed to the server. Period. That would hold true regardless of whether you're using GraphQL, REST, SOAP, etc.

Parse iOS SDK not sending application Id

I'm testing out deploying my own parse server following the steps in the Parse Server Guide. I've got the server up and running and have been able to create and fetch objects via curl. I built a simple iOS app using the Parse SDK (1.14.2). I've initialized the SDK with the app id and server url as described in the Parse Server Guide. When I try to make requests, I get back unauthorized from the server. Digging further, I noticed that the SDK is not sending the application id header to the server. I modified the SDK to send the application id header and everything works. Am I missing a configuration step somewhere?
This is because you are not passing the ClientKey. In swift 3 you would pass it like this in the didFinishLaunchingWithOptions.
// Init Parse
let configuration = ParseClientConfiguration {
$0.applicationId = PARSE_APP_KEY
$0.clientKey = PARSE_CLIENT_KEY
$0.server = PARSE_SERVER_URL
$0.isLocalDatastoreEnabled = true
}
Parse.initialize(with: configuration)
If you are falling when trying to test CloudCode, then its because your parse-server is not passing the Javascript key. So just make sure you initialize the server to do so if this issue is related to Parse.Cloud function.

Using Parse master key from the server and not cloud code

I recently implemented the security of my Parse app thinking that I could use the master key on my server (express not cloud code) to securely bypass my security implementations for admin/server level functions.
I'm using "parse": "^1.5.0",
in my package.json.
Right now in each of my express modules I have:
var Parse = require('parse').Parse;
Parse.initialize("Application ID", "Javascript Key", "Master Key");
Everything works fine without CLPs activated but with CLPs I can't do any read/write of the data with the server. I understand that I can move this to Cloud code and get it to work however I need to use a number of libraries in my code that Parse does not support and transporting all of the code to cloud code would be very tough.
What am I doing wrong?
Here's what worked for me.
/////////////////////////////////this is the top of the JS page/module/////
'use strict';
var Parse = require('parse/node');
Parse.initialize('app-id','js-key','master-key');
exports.create = function(req, res) {
Parse.Cloud.useMasterKey();
//now when you do a parse query or action you can bypass your security settings.
};

Mondrian olap - DriverManager.getConnection error

In my gwt web-app i'm using Mondrian. I have a method:
private Result executeMdxQuery(String queryString, Schema schema) throws InterruptedException {
CatalogLocatorImpl locator = new CatalogLocatorImpl();
Connection mdxConnection = DriverManager.getConnection(createConnectString(schema), locator);
return executeMdxQuery(queryString, mdxConnection);
}
result of createConnectString(schema) is
Provider=mondrian;Jdbc=jdbc:mysql://localhost/dds?user=root&password=qwerty;Catalog=/home/vskovalenko/schemas/air_new_zealand_monthly_traffic.xml;JdbcDrivers=com.mysql.jdbc.Driver;
all data within it is seems to be correct (at least db credentials and path to the file), this method throws no exception, it just silently dies and doesn't tell anything. Where should i loock to?
You should use the olap4j API to get a connection. This will allow you to let the application server manage and pool the connections to Mondrian.
If you require more control on the Mondrian server instance, you should take a look at the class MondrianServer.
add the following snippet to your code and try again:
Class.forName("mondrian.olap4j.MondrianOlap4jDriver");

Amazon S3 client connect through proxy - putObject getting NullPointerException

I've got this simple piece of code which is trying to upload a file to Amazon S3 via a proxy. This is the code:
BasicAWSCredentials basicCred = new BasicAWSCredentials("my_access_key", "my_secret_key");
ClientConfiguration clientCfg = new ClientConfiguration();
clientCfg.setProtocol(Protocol.HTTP);
//setup proxy connection:
clientCfg.setProxyHost("192.168.2.12");
clientCfg.setProxyPort(80);
AmazonS3 s3 = new AmazonS3Client(basicCred, clientCfg);
String bucketName = "mybucket";
String key = "/test/Capture.JPG";
File file = new File("d:/Test_Data/Capture.JPG");
System.out.println("Uploading a new object to S3 from a file");
s3.putObject(new PutObjectRequest(bucketName, key, file));
However this is the error I got from running the program:
Exception in thread "main" java.lang.NullPointerException
at com.amazonaws.util.BinaryUtils.fromHex(BinaryUtils.java:69)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1066)
at javaapplication8.JavaApplication8.main(JavaApplication8.java:48)
Java Result: 1
I'm using the latest aws 1.3.8 sdk from amazon. The proxy is set up in another PC next to me and it's just a simple Javascript proxy (http://www.catonmat.net/http-proxy-in-nodejs/)
I can't figure it out why. Somebody can help me, please?
here is another approach,
ClientConfiguration config = new ClientConfiguration();
config.setProtocol(Protocol.HTTPS);
config.setProxyHost("YOUR_PROXY_IP");
config.setProxyPort(YOUR_PROXY_PORT);
BasicAWSCredentials creds = new BasicAWSCredentials("YOUR_KEY", "YOUR_SECRET");
s3Client = AmazonS3ClientBuilder.standard()
.withClientConfiguration(config)
.withRegion(Regions.US_EAST_2)
.withCredentials(new AWSStaticCredentialsProvider(creds))
.build();
I ran into this issue as well. I stepped through everything in a debugger and found that the cause of the problem is the Amazon S3 client code expecting a header tag called "ETag", but the response contains "Etag", with a lowercase "t".
The headers are put into a Map<String,String>, so when the Amazon S3 client code calls get("ETag"), it gets back null, which is then fed into the hexData() method and blows up.
This seems to happen to a number of people using non-Amazon S3 services or accessing Amazon's AWS S3 service through a web proxy.
I don't know of a fix other than grabbing the Amazon client source, changing the Headers.ETAG value to "Etag" and building the JAR yourself.
Change the protocol to HTTPS.
$clientCfg.setProtocol(Protocol.HTTPS);

Resources