Comments (3)
Hi, can you provide an example with the arguments that you provide to the .create()
call?
I would be interested at seeing the invalid name that causes this issue.
from balena-sdk.
Hi,
I used a colon (:
) in the name, which caused the fail. So something like fleet:test
.
from balena-sdk.
Hi @bartversluijs,
It seems that this fell through the cracks of my inbox...
I think the issue that you are facing is that you are not waiting for the returned promise to resolve.
This causes the
auth.isLoggedIn()
function to always statetrue
, which isn't the case.
auth.isLoggedIn()
returns a promise, which if used directly in an if
statement could be confused with a true
boolean, but if you console.log(sdk.auth.isLoggedIn())
your console should print Promise {<pending>}
.
You can use .then()
or await
inside async functions. Let me also point you to our test cases that make sure that the returned promise resolves to false
when there is no logged in user:
balena-sdk/tests/integration/auth.spec.ts
Lines 19 to 23 in dde3a13
Similarly when calling application.create()
with invalid parameters, the function will not throw synchronously (especially since the name validation is done by our backend), but it will instead return a promise that will be rejected. You can handle that case by either using .catch((err) => { console.log(err) })
or using try catch with await like:
try {
const fleet = await sdk.models.application.create({
deviceType: 'raspberrypi3',
name: 'fleet:test',
organization: 'thgreasinomembersorg'
});
console.log(fleet);
} catch (err) {
console.error(err);
}
which should log something like:
BalenaRequestError: Request error: App name may only contain [a-zA-Z0-9_-].
Given that we do have test cases for these I will close the issue for now, but feel free to re-open or ask for further help here or in a new issue.
Kind regards,
Thodoris
from balena-sdk.
Related Issues (20)
- Should offer openFleet related methods
- Should add support for batch operations in the application model
- SDK marrying config to an os download HOT 1
- Should be able to register devices of a specific device type HOT 1
- Should also offer an ESM build
- Should completely remove the current_gateway_downloads property from *WithCurrentServiceDetails methods
- startOsUpdate will trigger even though a user lock exists
- Consider not offering plain `getAll()` methods for models like device/tags/etc in favor of the `getAllByXYZ()` HOT 4
- Should extend os.getAvailableOsVersions() & os.isSupportedOsUpgrade() to support ESR HOT 3
- Should move the sources from lib to src
- models.device.getOsVersion - Do not append variant for unified OS versions HOT 2
- Type error when adding an already expanded ReverseNavigationResource in the $select list HOT 2
- Should be able to use the service name in the service env var methods instead of the service id
- API endpoints for POSTING not working
- Streaming device logs may loose log entries HOT 2
- Breaking change/compatibility documentation?
- Device history model does not return data HOT 1
- [FEATURE] Add getAll to devices HOT 3
- Webpack failing to package balena-sdk in React/Next.js HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from balena-sdk.