Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/iceberg/catalog/rest/resource_paths.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Status ResourcePaths::SetBaseUri(const std::string& base_uri) {
return {};
}

Result<std::string> ResourcePaths::Config() const {
return std::format("{}/v1/config", base_uri_);
Result<std::string> ResourcePaths::Config(const std::string& base_uri) {
return std::format("{}/v1/config", base_uri);
}

Result<std::string> ResourcePaths::OAuth2Tokens() const {
Expand Down
3 changes: 1 addition & 2 deletions src/iceberg/catalog/rest/resource_paths.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <string>

#include "iceberg/catalog/rest/iceberg_rest_export.h"
#include "iceberg/catalog/rest/type_fwd.h"
#include "iceberg/result.h"
#include "iceberg/type_fwd.h"

Expand All @@ -48,7 +47,7 @@ class ICEBERG_REST_EXPORT ResourcePaths {
Status SetBaseUri(const std::string& base_uri);

/// \brief Get the /v1/config endpoint path.
Result<std::string> Config() const;
static Result<std::string> Config(const std::string& base_uri);

@wgtmac wgtmac Jan 5, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds good to remove SetBaseUri. However, it leads to confusion to make this a static function. I'd suggest to revert this function as you have created a new ResourcePaths based on the server config.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds good to remove SetBaseUri. However, it leads to confusion to make this a static function. I'd suggest to revert this function as you have created a new ResourcePaths based on the server config.

it's reasonable, i've reverted.


/// \brief Get the /v1/{prefix}/oauth/tokens endpoint path.
Result<std::string> OAuth2Tokens() const;
Expand Down
14 changes: 7 additions & 7 deletions src/iceberg/catalog/rest/rest_catalog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ std::unordered_set<Endpoint> GetDefaultEndpoints() {
}

/// \brief Fetch server config and merge it with client config
Result<CatalogConfig> FetchServerConfig(const ResourcePaths& paths,
Result<CatalogConfig> FetchServerConfig(const std::string& config_path,
const RestCatalogProperties& current_config) {
ICEBERG_ASSIGN_OR_RAISE(auto config_path, paths.Config());
HttpClient client(current_config.ExtractHeaders());
ICEBERG_ASSIGN_OR_RAISE(const auto response,
client.Get(config_path, /*params=*/{}, /*headers=*/{},
Expand Down Expand Up @@ -111,10 +110,9 @@ Result<std::shared_ptr<RestCatalog>> RestCatalog::Make(
if (!file_io) {
return InvalidArgument("FileIO is required to create RestCatalog");
}
ICEBERG_ASSIGN_OR_RAISE(
auto paths, ResourcePaths::Make(std::string(TrimTrailingSlash(uri)),
config.Get(RestCatalogProperties::kPrefix)));
ICEBERG_ASSIGN_OR_RAISE(auto server_config, FetchServerConfig(*paths, config));
ICEBERG_ASSIGN_OR_RAISE(auto config_uri,
ResourcePaths::Config(std::string(TrimTrailingSlash(uri))));
ICEBERG_ASSIGN_OR_RAISE(auto server_config, FetchServerConfig(config_uri, config));

std::unique_ptr<RestCatalogProperties> final_config = RestCatalogProperties::FromMap(
MergeConfigs(server_config.defaults, config.configs(), server_config.overrides));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this! Let's not complicate the PR. I think this change can be added without the test.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this! Let's not complicate the PR. I think this change can be added without the test.

Yes, i create a new pull request for it.https://github.com/apache/iceberg-cpp/pull/483/files

Expand All @@ -132,7 +130,9 @@ Result<std::shared_ptr<RestCatalog>> RestCatalog::Make(

// Update resource paths based on the final config
ICEBERG_ASSIGN_OR_RAISE(auto final_uri, final_config->Uri());
ICEBERG_RETURN_UNEXPECTED(paths->SetBaseUri(std::string(TrimTrailingSlash(final_uri))));
ICEBERG_ASSIGN_OR_RAISE(
Comment thread
wgtmac marked this conversation as resolved.
auto paths, ResourcePaths::Make(std::string(TrimTrailingSlash(final_uri)),
final_config->Get(RestCatalogProperties::kPrefix)));

return std::shared_ptr<RestCatalog>(
new RestCatalog(std::move(final_config), std::move(file_io), std::move(paths),
Expand Down
Loading