Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

Hyper3D: a refused file host keeps the paid result findable

islandmedfde27ccc4684
diff --git a/docs/guide/troubleshooting.md b/docs/guide/troubleshooting.md
index d1978f8a..6e870bed 100644
--- a/docs/guide/troubleshooting.md
+++ b/docs/guide/troubleshooting.md
@@ -133,7 +133,7 @@ If no pen is detected or pressure doesn't change:
| *Hyper3D rejected the API key* | Check the key, or create a new one in the API dashboard |
| *Your Hyper3D plan doesn't include this tier* | Basic API access covers Extreme Low and Low; choose one of those, or upgrade on hyper3d.ai |
| *Out of credits on your Hyper3D account* | Top up on hyper3d.ai |
-| *Refused the model file* | The result came from somewhere other than Hyper3D's servers, so SculptForge didn't download it. Try again; if it keeps happening, [report it](https://github.com/islandmed/SculptForge/issues) |
+| *Refused the model file* | The result came from somewhere other than Hyper3D's servers, so SculptForge didn't download it. The model isn't lost: it stays in your Hyper3D account (hyper3d.ai dashboard) under the task id in the message. If it keeps happening, [report it](https://github.com/islandmed/SculptForge/issues) |
### Brush Lab
diff --git a/src/ai/Hyper3D.cpp b/src/ai/Hyper3D.cpp
index 180b31e2..f612cd8d 100644
--- a/src/ai/Hyper3D.cpp
+++ b/src/ai/Hyper3D.cpp
@@ -10,6 +10,7 @@
#include "core/NetworkPolicy.h"
#include <algorithm>
+#include <cctype>
#include <chrono>
#include <cstdint>
#include <cstdlib>
@@ -328,10 +329,17 @@ GeneratorResult run(const AiSettings& s, const std::string& imagePath, const std
if (!listed.error.empty() || listed.status < 200 || listed.status >= 300) return fail(httpError(listed));
std::string fileUrl;
if (!parseDownload(listed.body, fileUrl, err)) return fail(err);
+ // A refused host: the paid result isn't lost, it stays in the user's Hyper3D account under this task id.
+ auto refusedHost = [&](const std::string& host) {
+ std::string id;
+ for (char c : taskUuid.substr(0, 64))
+ if (std::isalnum(static_cast<unsigned char>(c)) || c == '-') id += c;
+ return fail("Refused the model file: it isn't on Hyper3D's servers (" + host +
+ "). The model stays in your Hyper3D account (hyper3d.ai dashboard), task " + id);
+ };
if (!downloadUrlAllowed(fileUrl)) {
net::UrlParts u;
- return fail("Refused the model file: it isn't on Hyper3D's servers (" +
- (net::parseUrl(fileUrl, u) ? u.host : std::string("not an https address")) + ")");
+ return refusedHost(net::parseUrl(fileUrl, u) ? u.host : std::string("not an https address"));
}
if (!aiRequestAllowed("hyper3d", fileUrl, err)) return fail(err);
@@ -362,6 +370,11 @@ GeneratorResult run(const AiSettings& s, const std::string& imagePath, const std
});
if (tooBig) return fail("The model file is larger than 200 MB - refused");
if (p && p->cancel) return fail("Cancelled");
+ if (got.error.rfind("refused to download from ", 0) == 0) { // (a redirect left Hyper3D's servers)
+ net::UrlParts u;
+ const std::string to = got.error.substr(25);
+ return refusedHost(net::parseUrl(to, u) ? u.host : std::string("not an https address"));
+ }
if (!got.error.empty() || got.status != 200) return fail("Download failed: " + (got.error.empty() ? "HTTP " + std::to_string(got.status) : got.error));
if (!checkGlb(bytes, err)) return fail(err);
diff --git a/tests/test_hyper3d.cpp b/tests/test_hyper3d.cpp
index abaaa01b..9861fe90 100644
--- a/tests/test_hyper3d.cpp
+++ b/tests/test_hyper3d.cpp
@@ -393,11 +393,26 @@ TEST(hyper3d_bad_downloads_refused) {
fake.file = glb(R"({"asset":{"version":"2.0"}})");
GeneratorResult r = attempt(fake);
CHECK(!r.ok && r.error.find("evil.example") != std::string::npos && fake.calls.back().method == "POST");
+ // the paid result isn't lost: the task id and where to find it
+ CHECK(r.error.find("task task-1") != std::string::npos && r.error.find("hyper3d.ai dashboard") != std::string::npos);
+ CHECK(r.error.find(kKey) == std::string::npos);
}
{
FakeHyper3d fake; // plain http
fake.fileUrl = "http://file.hyper3d.com/model.glb";
- CHECK(!attempt(fake).ok && fake.calls.back().method == "POST");
+ GeneratorResult r = attempt(fake);
+ CHECK(!r.ok && fake.calls.back().method == "POST" && r.error.find("task task-1") != std::string::npos);
+ }
+ {
+ FakeHyper3d fake; // a redirect off Hyper3D's servers (as httpGetRestricted reports it)
+ hyper3d::setTransportForTests([&fake](const std::string& m, const std::string& u, const std::vector<std::string>& h,
+ const std::string& b) {
+ HttpResponse r = fake(m, u, h, b);
+ if (m == "GET") r = {0, {}, "refused to download from https://evil.example/x.glb"};
+ return r;
+ });
+ GeneratorResult r = hyper3d::run(s, {}, "a vase", nullptr);
+ CHECK(!r.ok && r.error.find("evil.example") != std::string::npos && r.error.find("task task-1") != std::string::npos);
}
{
FakeHyper3d fake; // not a GLB