Skip to content

Commit 779cc68

Browse files
committed
* (Apollon77) Prevent crash case (Sentry IOBROKER-SQL-16, IOBROKER-SQL-15, IOBROKER-SQL-1K)
* Add stalebot configuration * Add issue templates * update github action
1 parent 35e1b4e commit 779cc68

11 files changed

+301
-41
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: Bug report
3+
about: Something is not working as it should
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of what the bug is.
11+
12+
**To Reproduce**
13+
Steps to reproduce the behavior:
14+
1. Go to '...'
15+
2. Click on '...'
16+
3. Scroll down to '....'
17+
4. See error
18+
19+
**Expected behavior**
20+
A clear and concise description of what you expected to happen.
21+
22+
**Screenshots & Logfiles**
23+
If applicable, add screenshots and logfiles to help explain your problem.
24+
25+
**Versions:**
26+
- Adapter version: <adapter-version>
27+
- JS-Controller version: <js-controller-version> <!-- determine this with `iobroker -v` on the console -->
28+
- Node version: <node-version> <!-- determine this with `node -v` on the console -->
29+
- Operating system: <os-name>
30+
31+
**Additional context**
32+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/stale.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Configuration for probot-stale - https://github.com/probot/stale
2+
3+
# Number of days of inactivity before an Issue or Pull Request becomes stale
4+
daysUntilStale: 90
5+
6+
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
7+
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
8+
daysUntilClose: 7
9+
10+
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
11+
onlyLabels: []
12+
13+
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
14+
exemptLabels:
15+
- enhancement
16+
- security
17+
18+
# Set to true to ignore issues in a project (defaults to false)
19+
exemptProjects: true
20+
21+
# Set to true to ignore issues in a milestone (defaults to false)
22+
exemptMilestones: true
23+
24+
# Set to true to ignore issues with an assignee (defaults to false)
25+
exemptAssignees: false
26+
27+
# Label to use when marking as stale
28+
staleLabel: wontfix
29+
30+
# Comment to post when marking as stale. Set to `false` to disable
31+
markComment: >
32+
This issue has been automatically marked as stale because it has not had
33+
recent activity. It will be closed if no further activity occurs within the next 7 days.
34+
Please check if the issue is still relevant in the most current version of the adapter
35+
and tell us. Also check that all relevant details, logs and reproduction steps
36+
are included and update them if needed.
37+
Thank you for your contributions.
38+
39+
Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab.
40+
Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden.
41+
Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist,
42+
und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte
43+
enthalten sind bzw. aktualisiert diese.
44+
Vielen Dank für Eure Unterstützung.
45+
46+
# Comment to post when removing the stale label.
47+
# unmarkComment: >
48+
# Your comment here.
49+
50+
# Comment to post when closing a stale Issue or Pull Request.
51+
closeComment: >
52+
This issue has been automatically closed because of inactivity. Please open a new
53+
issue if still relevant and make sure to include all relevant details, logs and
54+
reproduction steps.
55+
Thank you for your contributions.
56+
57+
Dieses Problem wurde aufgrund von Inaktivität automatisch geschlossen. Bitte öffnet ein
58+
neues Issue, falls dies noch relevant ist und stellt sicher das alle relevanten Details,
59+
Logs und Reproduktionsschritte enthalten sind.
60+
Vielen Dank für Eure Unterstützung.
61+
62+
# Limit the number of actions per hour, from 1-30. Default is 30
63+
limitPerRun: 30
64+
65+
# Limit to only `issues` or `pulls`
66+
only: issues
67+
68+
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
69+
# pulls:
70+
# daysUntilStale: 30
71+
# markComment: >
72+
# This pull request has been automatically marked as stale because it has not had
73+
# recent activity. It will be closed if no further activity occurs. Thank you
74+
# for your contributions.
75+
76+
# issues:
77+
# exemptLabels:
78+
# - confirmed

.github/workflows/npmpublish.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# This is a composition of lint and test scripts
2+
# Make sure to update this file along with the others
3+
4+
name: Test and Release
5+
6+
# Run this job on all pushes and pull requests
7+
# as well as tags with a semantic version
8+
on:
9+
push:
10+
branches:
11+
- '*'
12+
tags:
13+
# normal versions
14+
- "v?[0-9]+.[0-9]+.[0-9]+"
15+
# pre-releases
16+
- "v?[0-9]+.[0-9]+.[0-9]+-**"
17+
pull_request: {}
18+
19+
jobs:
20+
# Performs quick checks before the expensive test runs
21+
check-and-lint:
22+
if: contains(github.event.head_commit.message, '[skip ci]') == false
23+
24+
runs-on: ubuntu-latest
25+
26+
strategy:
27+
matrix:
28+
node-version: [12.x]
29+
30+
steps:
31+
- uses: actions/checkout@v1
32+
- name: Use Node.js ${{ matrix.node-version }}
33+
uses: actions/setup-node@v1
34+
with:
35+
node-version: ${{ matrix.node-version }}
36+
37+
38+
- name: Install Dependencies
39+
run: npm install
40+
41+
# - name: Perform a type check
42+
# run: npm run check:ts
43+
# env:
44+
# CI: true
45+
# - name: Lint TypeScript code
46+
# run: npm run lint
47+
# - name: Test package files
48+
# run: npm run test:package
49+
50+
# Runs adapter tests on all supported node versions and OSes
51+
adapter-tests:
52+
if: contains(github.event.head_commit.message, '[skip ci]') == false
53+
54+
needs: [check-and-lint]
55+
56+
runs-on: ${{ matrix.os }}
57+
strategy:
58+
matrix:
59+
node-version: [10.x, 12.x, 14.x]
60+
os: [ubuntu-latest, windows-latest, macos-latest]
61+
62+
steps:
63+
- uses: actions/checkout@v1
64+
- name: Use Node.js ${{ matrix.node-version }}
65+
uses: actions/setup-node@v1
66+
with:
67+
node-version: ${{ matrix.node-version }}
68+
69+
- name: Install Dependencies
70+
run: npm install
71+
72+
# - name: Run local tests
73+
# run: npm test
74+
# - name: Run unit tests
75+
# run: npm run test:unit
76+
# - name: Run integration tests # (linux/osx)
77+
# if: startsWith(runner.OS, 'windows') == false
78+
# run: DEBUG=testing:* npm run test:integration
79+
# - name: Run integration tests # (windows)
80+
# if: startsWith(runner.OS, 'windows')
81+
# run: set DEBUG=testing:* & npm run test:integration
82+
83+
# Deploys the final package to NPM
84+
deploy:
85+
needs: [adapter-tests]
86+
87+
# Trigger this step only when a commit on master is tagged with a version number
88+
if: |
89+
contains(github.event.head_commit.message, '[skip ci]') == false &&
90+
github.event_name == 'push' &&
91+
github.event.base_ref == 'refs/heads/master' &&
92+
startsWith(github.ref, 'refs/tags/')
93+
runs-on: ubuntu-latest
94+
strategy:
95+
matrix:
96+
node-version: [12.x]
97+
98+
steps:
99+
- name: Checkout code
100+
uses: actions/checkout@v2
101+
102+
- name: Use Node.js ${{ matrix.node-version }}
103+
uses: actions/setup-node@v1
104+
with:
105+
node-version: ${{ matrix.node-version }}
106+
107+
- name: Extract the version and commit body from the tag
108+
# The body may be multiline, therefore we need to escape some characters
109+
run: |
110+
VERSION="${{ github.ref }}"
111+
VERSION=${VERSION##*/}
112+
VERSION=${VERSION##*v}
113+
echo "::set-env name=VERSION::$VERSION"
114+
BODY=$(git show -s --format=%b)
115+
BODY="${BODY//'%'/'%25'}"
116+
BODY="${BODY//$'\n'/'%0A'}"
117+
BODY="${BODY//$'\r'/'%0D'}"
118+
echo "::set-env name=BODY::$BODY"
119+
120+
- name: Install Dependencies
121+
run: npm install
122+
123+
# - name: Create a clean build
124+
# run: npm run build
125+
- name: Publish package to npm
126+
run: |
127+
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
128+
npm whoami
129+
npm publish
130+
131+
- name: Create Github Release
132+
uses: actions/create-release@v1
133+
env:
134+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135+
with:
136+
tag_name: ${{ github.ref }}
137+
release_name: Release v${{ env.VERSION }}
138+
draft: false
139+
# Prerelease versions create prereleases on Github
140+
prerelease: ${{ contains(env.VERSION, '-') }}
141+
body: ${{ env.BODY }}
142+
143+
- name: Notify Sentry.io about the release
144+
run: |
145+
npm i -g @sentry/cli
146+
export SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
147+
export SENTRY_URL=https://sentry.iobroker.net
148+
export SENTRY_ORG=iobroker
149+
export SENTRY_PROJECT=iobroker-sql
150+
export SENTRY_VERSION=iobroker.sql@${{ env.VERSION }}
151+
sentry-cli releases new $SENTRY_VERSION
152+
sentry-cli releases finalize $SENTRY_VERSION
153+
154+
# Add the following line BEFORE finalize if repositories are connected in Sentry
155+
# sentry-cli releases set-commits $SENTRY_VERSION --auto
156+
157+
# Add the following line BEFORE finalize if sourcemap uploads are needed
158+
# sentry-cli releases files $SENTRY_VERSION upload-sourcemaps build/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ tmp
44
admin/i18n/flat.txt
55
admin/i18n/*/flat.txt
66
iob_npm.done
7+
package-lock.json

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ language: node_js
66
node_js:
77
- '10'
88
- '12'
9-
- '13'
9+
- '14'
1010
- 'node'
1111
services:
1212
- mysql

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,10 @@ sendTo('sql.0', 'getEnabledDPs', {}, function (result) {
403403
- **Storage retention**: How long the values will be stored in the DB.
404404

405405
## Changelog
406+
407+
### __WORK IN PROGRESS__
408+
* (Apollon77) Prevent crash case (Sentry IOBROKER-SQL-16, IOBROKER-SQL-15, IOBROKER-SQL-1K)
409+
406410
### 1.14.2 (2020-06-23)
407411
* (bluefox) Fixed error for data storage
408412

appveyor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ environment:
33
matrix:
44
- nodejs_version: '10'
55
- nodejs_version: '12'
6-
- nodejs_version: '13'
76
- nodejs_version: '14'
87
platform:
98
- x86

main.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function startAdapter(options) {
108108
const now = Date.now();
109109
const formerAliasId = aliasMap[id] ? aliasMap[id] : id;
110110

111-
if (obj && obj.common && obj.common.custom && obj.common.custom[adapter.namespace] && obj.common.custom[adapter.namespace].enabled) {
111+
if (obj && obj.common && obj.common.custom && obj.common.custom[adapter.namespace] && typeof obj.common.custom[adapter.namespace] === 'object' && obj.common.custom[adapter.namespace].enabled) {
112112
const realId = id;
113113
let checkForRemove = true;
114114

@@ -339,8 +339,8 @@ function connect(callback) {
339339
let params = {
340340
server: adapter.config.host, // needed for MSSQL
341341
host: adapter.config.host, // needed for PostgeSQL , MySQL
342-
user: adapter.config.user,
343-
password: adapter.config.password,
342+
user: adapter.config.user || '',
343+
password: adapter.config.password || '',
344344
max_idle: (adapter.config.dbtype === 'sqlite') ? 1 : 2
345345
};
346346

@@ -366,10 +366,6 @@ function connect(callback) {
366366
} else
367367
// special solution for postgres. Connect first to Db "postgres", create new DB "iobroker" and then connect to "iobroker" DB.
368368
if (_client !== true && adapter.config.dbtype === 'postgresql') {
369-
if (adapter.config.dbtype === 'postgresql') {
370-
params.database = 'postgres';
371-
}
372-
373369
if (!adapter.config.dbtype) {
374370
return adapter.log.error('DB Type is not defined!');
375371
} else
@@ -2608,7 +2604,7 @@ function main() {
26082604
sqlDPs[id].dbtype = storedType;
26092605
}
26102606

2611-
if (!sqlDPs[id][adapter.namespace]) {
2607+
if (!sqlDPs[id][adapter.namespace] || typeof sqlDPs[id][adapter.namespace] !== 'object' || sqlDPs[id][adapter.namespace].enabled === false) {
26122608
delete sqlDPs[id];
26132609
} else {
26142610
count++;

0 commit comments

Comments
 (0)